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

SCM Repository

[diderot] Annotation of /branches/ein16/test/zslice-hess2.diderot
ViewVC logotype

Annotation of /branches/ein16/test/zslice-hess2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3269 - (view) (download)
Original Path: branches/charisee_dev/test/zslice-hess2.diderot

1 : glk 1441 // zslice-hess2
2 :     //
3 :     // Demo of field of tensor[2,2] from image of tensor[2,2]
4 :     //
5 :     // Process output with:
6 :     // unu reshape -s 2 200 200 -i zslice-hess2.txt | unu pad -min 0 0 0 -max 2 M M -b wrap | unu quantize -b 8 -o zslice-hess2.png
7 :    
8 :     int gridSize = 200;
9 : jhr 3063 field#1(2)[2] G = ctmr ⊛ image("../data/ddro-80-grad.nrrd");
10 : glk 1441
11 :    
12 :     /* HEY: Not able to load nrrd as tensor[2,2] image; error is:
13 :    
14 :     [zslice-hess2.diderot] Error: image file "../data/ddro-80-hess.nrrd" has range tensor[4], expected tensor[2,2]
15 :     uncaught exception Fail [Fail: Error in compiling zslice-hess2.diderot]
16 :     raised at common/phase-timer.sml:76.50-76.52
17 :     raised at common/phase-timer.sml:76.50-76.52
18 :     raised at driver/main.sml:27.39-27.76
19 :    
20 :     Can comment out following two lines, and below replace "hess = H(pos)"
21 :     with "hess = ∇⊗G(pos)", to get program to run and generate similar output
22 :     */
23 : jhr 3063 image(2)[2,2] Himg = image("../data/ddro-80-hess.nrrd");
24 : glk 1441 field#1(2)[2,2] H = ctmr ⊛ Himg;
25 :    
26 :     strand sample (int ui, int vi) {
27 :     vec2 pos = [lerp(0.0, 1.0, -0.5, real(ui), real(gridSize)-0.5),
28 :     lerp(0.0, 1.0, -0.5, real(vi), real(gridSize)-0.5)];
29 :     output vec2 val = [0.0,0.0];
30 :     vec2 grad = [0.0,0.0];
31 :     tensor[2,2] hess = [[0.0,0.0],[0.0,0.0]];
32 :     update {
33 :     grad = G(pos);
34 :     //hess = ∇⊗G(pos); // use this as long as tensor[2,2] fields not working
35 :     hess = H(pos); // use this when tensor[2,2] fields working
36 :     val = hess • grad;
37 :     stabilize;
38 :     }
39 :     }
40 :    
41 :     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