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

SCM Repository

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

Annotation of /branches/charisee/rtest/tests/mip/mip.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3060 - (view) (download)

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