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

SCM Repository

[diderot] View of /tests/lamont-tests/ridge3d.diderot
ViewVC logotype

View of /tests/lamont-tests/ridge3d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (download) (annotate)
Tue Sep 27 20:54:47 2016 UTC (2 years, 9 months ago) by glk
File size: 2921 byte(s)
initial result of svn export --username anonsvn --password=anonsvn https://svn.smlnj-gforge.cs.uchicago.edu/svn/diderot/branches/vis15/src/tests/
/*! \file ridge3d.diderot
 *
 * \author Gordon Kindlmann
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 */

/* possible computation and post-processing:

foreach S ( 170 190 210 230 250 270 290 )
  echo $S
  ./ridge3d -gridSize 120 -strnMin $S
  mv pos.nrrd pos-${S}.nrrd
end

unu join -i pos-{170,190,210,230,250,270,290}.nrrd -a 1 \
 | unu jhisto -min 21.6401 -175.8792 -188.0000 \
   -max 91.6401 -75.8792 -118.0000 -b 70 140 70 -t float \
 | unu 1op log1p \
 | ../../bin/dnorm -i - \
 | unu 2op gt - 3 \
 | unu dist -th 0.5 -inv -sgn \
 | unu 2op gt - -1 \
 | unu quantize -b 8 \
 | unu ccfind -c 1 -v vals.nrrd \
 | unu ccmerge -s 2000 -c 1 -d -1 -v vals.nrrd -revalue \
 | unu ccfind -c 1 -v vals.nrrd \
 | unu ccmerge -s 2000 -c 1 -d -1 -v vals.nrrd -revalue \
 | unu dist -th 128 -inv -sgn \
 | unu pad -min -1 -1 -1 -max M+1 M+1 M+1 -b pad -v -3 \
 | unu resample -s x2 x2 x2  -k bspln3 -o lung-vis.nrrd
rm -f vals.nrrd 

echo with fog
~/Deft/src/Deft_iso -i lung-vis.nrrd \
-usecam -fr -514.784 1271.16 -1262.16 -at 61.5794 -112.78 -148.393 \
-up 0.570448 0.645888 0.507364 -rh -ar \
-dn -38.7956 -df 50 -fv 2.18834 -is 1280 960

overrgb -i 000000.png -b 0.1 0.15 0.2 -o lung-vis.png

*/

input int gridSize = 120;
field#2(3)[] F = bspln3 ⊛ image("data/lungcrop.nrrd");
input int stepsMax = 30;
input real epsilon = 0.001;
input real travelMax = 5.0;
input real strnMin = 170.0;

strand sample (int ui, int vi, int wi) {
    output vec3 pos = [lerp(21.6401, 21.6401 + 140.0*0.5,
                              -0.5, real(ui), real(gridSize)-0.5),
                       lerp(-175.8792, -175.8792 + 200.0*0.5, 
                              -0.5, real(vi), real(gridSize)-0.5),
                       lerp(-188.0000, -188.0000 + 140.0*0.5,
                              -0.5, real(wi), real(gridSize)-0.5)];
    int steps = 0;
    real travel = 0.0;
    update {
        if (!inside(pos, F) || steps > stepsMax || travel > travelMax)
	    die;
        real gmag = |∇F(pos)|;
        if (gmag == 0.0)    // can't compute step if |∇F|, so have to bail
	    die;
        vec3 grad = ∇F(pos);
        tensor[3,3] hess = ∇⊗∇F(pos);

        real{3} eval = evals(hess);
        real strn = -eval{1};
        vec3{3} evec = evecs(hess);
        vec3 dir = normalize((evec{2}⊗evec{2} + evec{1}⊗evec{1})•grad);

        real fdd = grad•dir;
        real sdd = dir•hess•dir;
        vec3 delta = (0.1 if sdd >= 0.0 else -fdd/sdd)*dir;
        if (|delta| < epsilon) {
           if (strn >= strnMin)
             stabilize;
           die;
        }
        pos += delta;
        steps += 1;
        travel += |delta|;
    }
}

initially { sample(ui, vi, wi) | 
             wi in 0..(gridSize-1), 
             vi in 0..(gridSize-1), 
             ui in 0..(gridSize-1) };

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