1 : |
jhr |
1584 |
/*! \file bmark-teem.c
|
2 : |
|
|
*
|
3 : |
|
|
* \author Gordon Kindlmann
|
4 : |
|
|
*/
|
5 : |
|
|
|
6 : |
|
|
/*
|
7 : |
|
|
* COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
|
8 : |
|
|
* All rights reserved.
|
9 : |
|
|
*/
|
10 : |
|
|
|
11 : |
glk |
1582 |
#include <stdio.h>
|
12 : |
|
|
#include <math.h>
|
13 : |
|
|
#include "teem/nrrd.h"
|
14 : |
|
|
#include "teem/gage.h"
|
15 : |
|
|
#include "teem/ell.h"
|
16 : |
|
|
|
17 : |
jhr |
1584 |
static double GetTime ()
|
18 : |
|
|
{
|
19 : |
|
|
struct timeval tv;
|
20 : |
|
|
|
21 : |
|
|
gettimeofday (&tv, 0);
|
22 : |
|
|
|
23 : |
|
|
return (double)tv.tv_sec + 0.000001 * (double)tv.tv_usec;
|
24 : |
|
|
}
|
25 : |
|
|
|
26 : |
|
|
#define STATIC_INLINE static inline
|
27 : |
|
|
|
28 : |
|
|
int inside (double pos[3]) {
|
29 : |
glk |
1582 |
if(pos[0] < -0.5 || pos[0] > 175.5) return 0;
|
30 : |
|
|
if(pos[1] < -0.5 || pos[1] > 186.5) return 0;
|
31 : |
|
|
if(pos[2] < -0.5 || pos[2] > 189.5) return 0;
|
32 : |
|
|
return 1;
|
33 : |
|
|
}
|
34 : |
|
|
|
35 : |
|
|
int main (int argc, const char *argv[]) {
|
36 : |
|
|
hestOpt *hopt=NULL;
|
37 : |
|
|
hestParm *hparm;
|
38 : |
|
|
airArray *mop;
|
39 : |
|
|
const char *me;
|
40 : |
|
|
|
41 : |
|
|
#define DATA_IN_STR "../../data/lungcrop.nrrd"
|
42 : |
|
|
unsigned int gridPoints, stepsMax;
|
43 : |
|
|
Nrrd *nin, *nout, *npos;
|
44 : |
|
|
char *err, *outS;
|
45 : |
|
|
float epsilon;
|
46 : |
|
|
|
47 : |
|
|
mop = airMopNew();
|
48 : |
|
|
hparm = hestParmNew();
|
49 : |
|
|
airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways);
|
50 : |
|
|
nout = nrrdNew();
|
51 : |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
|
52 : |
|
|
|
53 : |
|
|
hparm->noArgsIsNoProblem = AIR_TRUE;
|
54 : |
|
|
me = argv[0];
|
55 : |
|
|
hestOptAdd(&hopt, "gridSize", "grid points", airTypeUInt, 1, 1,
|
56 : |
|
|
&gridPoints, "120",
|
57 : |
|
|
"number of points along volume edge");
|
58 : |
|
|
hestOptAdd(&hopt, "stepsMax", "# iters", airTypeUInt, 1, 1,
|
59 : |
|
|
&stepsMax, "20",
|
60 : |
|
|
"# iterations allowed for feature detection");
|
61 : |
|
|
hestOptAdd(&hopt, "epsilon", "convg", airTypeFloat, 1, 1,
|
62 : |
|
|
&epsilon, "0.005", "convergence threshold");
|
63 : |
|
|
|
64 : |
|
|
hestParseOrDie(hopt, argc-1, argv+1, hparm,
|
65 : |
|
|
me, "ridge3d", AIR_TRUE, AIR_TRUE, AIR_TRUE);
|
66 : |
|
|
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
|
67 : |
|
|
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
|
68 : |
|
|
|
69 : |
|
|
nin = nrrdNew();
|
70 : |
|
|
airMopAdd(mop, nin, (airMopper)nrrdNuke, airMopAlways);
|
71 : |
|
|
if (nrrdLoad(nin, DATA_IN_STR, NULL)) {
|
72 : |
|
|
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
|
73 : |
|
|
fprintf(stderr, "Trouble reading:\n%s", err);
|
74 : |
|
|
airMopError(mop);
|
75 : |
|
|
return 1;
|
76 : |
|
|
}
|
77 : |
|
|
|
78 : |
|
|
gageContext *ctx;
|
79 : |
|
|
gagePerVolume *pvl;
|
80 : |
|
|
double kparm[NRRD_KERNEL_PARMS_NUM] = {0.0};
|
81 : |
|
|
ctx = gageContextNew();
|
82 : |
|
|
airMopAdd(mop, ctx, (airMopper)gageContextNix, airMopAlways);
|
83 : |
|
|
pvl = gagePerVolumeNew(ctx, nin, gageKindScl);
|
84 : |
|
|
if (gagePerVolumeAttach(ctx, pvl)
|
85 : |
|
|
|| gageKernelSet(ctx, gageKernel00, nrrdKernelBSpline3, kparm)
|
86 : |
|
|
|| gageKernelSet(ctx, gageKernel11, nrrdKernelBSpline3D, kparm)
|
87 : |
|
|
|| gageKernelSet(ctx, gageKernel22, nrrdKernelBSpline3DD, kparm)
|
88 : |
|
|
|| gageQueryItemOn(ctx, pvl, gageSclGradVec)
|
89 : |
|
|
|| gageQueryItemOn(ctx, pvl, gageSclHessian)
|
90 : |
|
|
|| gageUpdate(ctx)) {
|
91 : |
|
|
airMopAdd(mop, err = biffGetDone(GAGE), airFree, airMopAlways);
|
92 : |
|
|
fprintf(stderr, "Trouble setting up gage context:\n%s", err);
|
93 : |
|
|
airMopError(mop);
|
94 : |
|
|
return 1;
|
95 : |
|
|
}
|
96 : |
|
|
|
97 : |
|
|
npos = nrrdNew();
|
98 : |
|
|
airMopAdd(mop, npos, (airMopper)nrrdNuke, airMopAlways);
|
99 : |
|
|
|
100 : |
|
|
int ui, vi, wi;
|
101 : |
|
|
float xx, yy, zz;
|
102 : |
|
|
|
103 : |
jhr |
1584 |
double t0 = GetTime(); // start timing
|
104 : |
|
|
|
105 : |
|
|
/* COMPUTATION GOES HERE */
|
106 : |
|
|
|
107 : |
|
|
double totalTime = GetTime() - t0; // report timing
|
108 : |
|
|
printf("usr=%f\n", totalTime);
|
109 : |
|
|
|
110 : |
glk |
1582 |
airMopOkay(mop);
|
111 : |
|
|
return 0;
|
112 : |
|
|
}
|