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

SCM Repository

[diderot] Annotation of /branches/lamont/test/laplgrad.diderot
ViewVC logotype

Annotation of /branches/lamont/test/laplgrad.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2081 - (view) (download)

1 : glk 1961
2 :     // laplgrad: tests if laplacian gradient is being computed correctly
3 :    
4 :     // process output with:
5 :     // unu tile -i out.nrrd -a 0 1 2 -s 2 2 | unu quantize -b 8 -o laplgrad.png
6 :    
7 :     input real epsilon = 0.0001;
8 :     int gridSize = 300;
9 :     field#4(2)[] F = bspln5 ⊛ image("../data/ddro-64.nrrd");
10 :     input bool norm = false;
11 :    
12 :     strand sample (int ui, int vi) {
13 :     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 :     vec2 stepX = [epsilon,0.0];
16 :     vec2 stepY = [0.0,epsilon];
17 :     output vec4 out = [0.0,0.0,0.0,0.0];
18 :     update {
19 :     if (!(inside(pos, F)
20 :     && inside(pos+stepX, F) && inside(pos-stepX, F)
21 :     && inside(pos+stepY, F) && inside(pos-stepY, F) )) {
22 :     stabilize;
23 :     }
24 :     tensor[2] dgrad = [(trace(∇⊗∇F(pos+stepX)) - trace(∇⊗∇F(pos-stepX)))/(2.0*epsilon),
25 :     (trace(∇⊗∇F(pos+stepY)) - trace(∇⊗∇F(pos-stepY)))/(2.0*epsilon)];
26 :     tensor[2] lgrad = identity[2]:∇⊗∇⊗∇F(pos);
27 :     if (norm) {
28 :     dgrad = normalize(dgrad);
29 :     lgrad = normalize(lgrad);
30 :     }
31 :     out = [dgrad[0], dgrad[1],
32 :     lgrad[0], lgrad[1]];
33 :     stabilize;
34 :     }
35 :     }
36 :    
37 :     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