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

SCM Repository

[diderot] Annotation of /branches/vis12-cl/test/lzc2d-brute-BUG2.diderot
ViewVC logotype

Annotation of /branches/vis12-cl/test/lzc2d-brute-BUG2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2402 - (view) (download)

1 : glk 1954 // lzc2d-brute
2 :     //
3 :     // Demo of laplacian zero-crossing edges via brute-force search
4 :     // and then Illinois false position
5 :     //
6 :     // Process output with:
7 :     // unu jhisto -i pos.nrrd -b 512 512 -min 0 0 -max 1 1 | unu 2op neq - 0 | unu quantize -b 8 -o lzc2d.png
8 :    
9 :     int gridSize = 300;
10 :     field#3(2)[] F = bspln5 ⊛ image("../data/ddro-80.nrrd");
11 :     int stepsMax = 30;
12 :     real epsilon = 0.00001;
13 :    
14 :     strand sample (int ui, int vi) {
15 :     output vec2 pos = [lerp(0.0, 1.0, -0.5, real(ui), real(gridSize)-0.5),
16 :     lerp(0.0, 1.0, -0.5, real(vi), real(gridSize)-0.5)];
17 :     vec2 posA=pos;
18 :     vec2 posB=pos;
19 :     int stepsNum = 0;
20 :     int side = 0;
21 :     real step = 0.004;
22 :     real fA=0.0;
23 :     real fB=0.0;
24 :     real A=0.0;
25 :     real B=1.0;
26 :     bool searching = true;
27 :     update {
28 :     // We bail if we're no longer inside or taken too many steps.
29 :     if (!inside(pos, F) || stepsNum > stepsMax) {
30 :     die;
31 :     }
32 :     if (searching) {
33 :     posA = pos;
34 :     real ll = trace(∇⊗∇F(pos));
35 :     // vec2 dir = normalize(∇F(pos));
36 :     vec2 dir = normalize(identity[2]:∇⊗∇⊗∇F(pos));
37 :     /* BUG: this third-derivative-based setting of dir
38 :     (gradient-based setting works fine). Compiling gives:
39 :     high-il DFA: cpu = 0.000 seconds, gc = 0.000 seconds, 11 nodes, 10 visits, 1 iterations
40 :     high-il DFA: cpu = 0.001 seconds, gc = 0.000 seconds, 48 nodes, 47 visits, 1 iterations
41 :     high-il DFA: cpu = 0.004 seconds, gc = 0.000 seconds, 157 nodes, 156 visits, 1 iterations
42 :     ***** Internal error after translation to HighIL: see log file for details
43 :     */
44 :     real sgn = 1.0 if ll > 0.0 else -1.0;
45 :     posB = pos + sgn*step*dir;
46 :     searching = trace(∇⊗∇F(posB))*ll > 0.0;
47 :     if (!searching) {
48 :     /* set up next phase */
49 :     fA = trace(∇⊗∇F(posA));
50 :     fB = trace(∇⊗∇F(posB));
51 :     }
52 :     } else {
53 :     pos = lerp(posA, posB, fA, 0.0, fB);
54 :     real fs = trace(∇⊗∇F(pos));
55 :     if (0.0 == fs) {
56 :     stabilize;
57 :     }
58 :     if (fs*fB > 0.0) { /* not between s and b */
59 :     posB = pos;
60 :     fB = fs;
61 :     if (1 == side) {
62 :     fA /= 2.0;
63 :     }
64 :     side = 1;
65 :     } else { /* not between a and s */
66 :     posA = pos;
67 :     fA = fs;
68 :     if (-1 == side) {
69 :     fB /= 2.0;
70 :     }
71 :     side = -1;
72 :     }
73 :     if (|posA - posB| < epsilon ) {
74 :     if (|∇F(pos)| < 180.0) {
75 :     pos = [-1.0,-1.0];
76 :     }
77 :     stabilize;
78 :     }
79 :     }
80 :     stepsNum += 1;
81 :     }
82 :     }
83 :    
84 :     initially { sample(ui, vi) | vi in 0..(gridSize-1), ui in 0..(gridSize-1) };

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