1 |
|
|
/* |
2 |
|
|
Teem: Tools to process and visualize scientific data and images . |
3 |
|
|
Copyright (C) 2013, 2012, 2011, 2010, 2009 University of Chicago |
4 |
|
|
Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann |
5 |
|
|
Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah |
6 |
|
|
|
7 |
|
|
This library is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU Lesser General Public License |
9 |
|
|
(LGPL) as published by the Free Software Foundation; either |
10 |
|
|
version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
The terms of redistributing and/or modifying this software also |
12 |
|
|
include exceptions to the LGPL that facilitate static linking. |
13 |
|
|
|
14 |
|
|
This library is distributed in the hope that it will be useful, |
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 |
|
|
Lesser General Public License for more details. |
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU Lesser General Public License |
20 |
|
|
along with this library; if not, write to Free Software Foundation, Inc., |
21 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#include "ten.h" |
25 |
|
|
#include "privateTen.h" |
26 |
|
|
|
27 |
|
|
#define INFO "Quantize directions of diffusion" |
28 |
|
|
static const char *_tend_evqInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". Because VTK doesn't do multi-dimensional colormaps, we have to " |
31 |
|
|
"quantize directions of diffusion (usually just the principal eigenvector) " |
32 |
|
|
"in order to create the usual XYZ<->RGB coloring. Because " |
33 |
|
|
"eigenvector directions are poorly defined in regions of low " |
34 |
|
|
"anisotropy, the length of the vector (pre-quantization) is modulated " |
35 |
|
|
"by anisotropy, requiring the selection of some anisotropy metric."); |
36 |
|
|
|
37 |
|
|
int |
38 |
|
|
tend_evqMain(int argc, const char **argv, const char *me, |
39 |
|
|
hestParm *hparm) { |
40 |
|
|
int pret; |
41 |
|
2 |
hestOpt *hopt = NULL; |
42 |
|
1 |
char *perr, *err; |
43 |
|
|
airArray *mop; |
44 |
|
|
|
45 |
|
1 |
int which, aniso, dontScaleByAniso; |
46 |
|
1 |
Nrrd *nin, *nout; |
47 |
|
1 |
char *outS; |
48 |
|
|
|
49 |
|
1 |
hestOptAdd(&hopt, "c", "evec index", airTypeInt, 1, 1, &which, "0", |
50 |
|
|
"Which eigenvector should be quantized: \"0\" for the " |
51 |
|
|
"direction of fastest diffusion (eigenvector associated " |
52 |
|
|
"with largest eigenvalue), \"1\" or \"2\" for other two " |
53 |
|
|
"eigenvectors (associated with middle and smallest eigenvalue)"); |
54 |
|
1 |
hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &aniso, NULL, |
55 |
|
|
"Which anisotropy metric to scale the eigenvector " |
56 |
|
|
"with. " TEN_ANISO_DESC, |
57 |
|
1 |
NULL, tenAniso); |
58 |
|
1 |
hestOptAdd(&hopt, "ns", NULL, airTypeInt, 0, 0, &dontScaleByAniso, NULL, |
59 |
|
|
"Don't attenuate the color by anisotropy. By default (not " |
60 |
|
|
"using this option), regions with low or no anisotropy are " |
61 |
|
|
"very dark colors or black"); |
62 |
|
1 |
hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", |
63 |
|
1 |
"input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); |
64 |
|
1 |
hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", |
65 |
|
|
"output image (floating point)"); |
66 |
|
|
|
67 |
|
1 |
mop = airMopNew(); |
68 |
|
1 |
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); |
69 |
✓✗ |
2 |
USAGE(_tend_evqInfoL); |
70 |
|
|
PARSE(); |
71 |
|
|
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); |
72 |
|
|
|
73 |
|
|
nout = nrrdNew(); |
74 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
75 |
|
|
if (tenEvqVolume(nout, nin, which, aniso, !dontScaleByAniso)) { |
76 |
|
|
airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); |
77 |
|
|
fprintf(stderr, "%s: trouble quantizing eigenvectors:\n%s\n", me, err); |
78 |
|
|
airMopError(mop); return 1; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
if (nrrdSave(outS, nout, NULL)) { |
82 |
|
|
airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); |
83 |
|
|
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); |
84 |
|
|
airMopError(mop); return 1; |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
airMopOkay(mop); |
88 |
|
|
return 0; |
89 |
|
1 |
} |
90 |
|
|
TEND_CMD(evq, INFO); |