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

SCM Repository

[diderot] Annotation of /branches/charisee/ertest/vispaper/iso3d/cniso3d.diderot
ViewVC logotype

Annotation of /branches/charisee/ertest/vispaper/iso3d/cniso3d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2964 - (view) (download)

1 : glk 2940
2 :     /*
3 :    
4 :     ../../../bin/diderotc cniso3d.diderot \
5 :     && ./cniso3d \
6 :     && unu crop -i cniso3d.txt -min 0 0 -max 1 M | \
7 :     unu jhisto -b 600 600 -min -1.2 -1.2 -max 1.2 1.2 -t float | \
8 :     unu 1op log1p | \
9 :     unu quantize -b 8 -o cniso3d.png \
10 :     && open cniso3d.png
11 :    
12 :     */
13 :    
14 :     field#4(3)[] V= c4hexic ⊛ load("canny.nrrd");
15 : jhr 2944 //field#3(3)[3] G = ∇V;
16 :     field#2(3)[3] G = ∇V;
17 : glk 2940 field#2(3)[3,3] H = ∇⊗∇V;
18 :     field#2(3)[] F = G•H•G/|G|;
19 :    
20 : glk 2964 input int grid = 30;
21 : glk 2940 int stepsMax = 10;
22 :     real epsilon = 0.0001;
23 :    
24 :     strand RootFind(real xi,real xj, real xk) {
25 :     output vec3 x = [xi,xj,xk];
26 :     int steps = 0;
27 :     update {
28 :     // Stop if we're no longer inside or taken too many steps.
29 :     if (!inside(x, V) || steps > stepsMax)
30 :     die;
31 :     // subsequent expressions are undefined if |∇F| is zero
32 :     if (|∇F(x)| == 0.0)
33 :     die;
34 :     // ALSO, for canny, bail if gradient magnitude is too low
35 : glk 2964 if (|∇V(x)| < 4)
36 : glk 2940 die;
37 :     // the Newton-Raphson step
38 :     vec3 delta = normalize(∇F(x)) * F(x)/|∇F(x)|;
39 :     // we've converged if the change is small enough
40 :     if (|delta| < epsilon)
41 :     stabilize;
42 : glk 2964 print( xi, ",", xj, ",", xk, ": ", x, " -= ", delta, "(step ", steps, ")\n");
43 : glk 2940 x -= delta;
44 :     steps += 1;
45 :     }
46 :     }
47 :    
48 :     initially { RootFind(lerp(-2, 2, -0.5, ui, grid-0.5),
49 :     lerp(-2, 2, -0.5, vi, grid-0.5),
50 :     lerp(-2, 2, -0.5, wi, grid-0.5))
51 :     | wi in 0..(grid-1), vi in 0..(grid-1), ui in 0..(grid-1) };

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