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

SCM Repository

[diderot] Annotation of /trunk/rtest/tests/mip/mip.diderot
ViewVC logotype

Annotation of /trunk/rtest/tests/mip/mip.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

1 : jhr 2636 /*! \file mip.diderot
2 :     *
3 :     * \author Gordon Kindlmann
4 :     */
5 : glk 1189
6 : jhr 2636 /*
7 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
8 :     *
9 :     * COPYRIGHT (c) 2015 The University of Chicago
10 : jhr 2636 * All rights reserved.
11 :     */
12 :    
13 :    
14 : glk 1194 // mip:
15 :     //
16 :     // does maximum intensity projection
17 :    
18 : glk 1189 vec3 camEye = [6.65584, 13.2759, 8.55225];
19 : jhr 2636 vec3 camAt = [0, 0, 0];
20 :     vec3 camUp = [0, 0, 1];
21 : glk 1189 real camNear = -1.0;
22 :     real camFar = 1.0;
23 :     real camFOV = 6.0;
24 :     int imgResU = 320;
25 :     int imgResV = 240;
26 :     real rayStep = 0.01;
27 :    
28 :     real camDist = |camAt - camEye|;
29 :     real camVspNear = camNear + camDist;
30 :     real camVspFar = camFar + camDist;
31 :     vec3 camN = normalize(camAt - camEye);
32 :     vec3 camU = normalize(camN × camUp);
33 :     vec3 camV = camN × camU;
34 :     real camVmax = tan(camFOV*π/360.0)*camDist;
35 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
36 :    
37 : jhr 2636 field#0(3)[] F = tent ⊛ image("../../data/ring.nrrd");
38 : glk 1189
39 :     strand RayCast (int ui, int vi) {
40 :     real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
41 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
42 :     vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
43 :    
44 :     real rayN = camVspNear;
45 :     output real maxval = -0.6;
46 :    
47 :     update {
48 :     vec3 rayPos = camEye + rayN*rayVec;
49 :     if (inside (rayPos,F)) {
50 :     maxval = max(maxval, F(rayPos));
51 :     }
52 :     if (rayN > camVspFar)
53 :     stabilize;
54 : jhr 1296 rayN += rayStep;
55 : glk 1189 }
56 :     }
57 :    
58 :     initially [ RayCast(ui, vi) | vi in 0..(imgResV-1), ui in 0..(imgResU-1) ];

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