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 "Make an RGB volume from an eigenvector and an anisotropy" |
28 |
|
|
static const char *_tend_evecrgbInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". "); |
31 |
|
|
|
32 |
|
|
int |
33 |
|
|
tend_evecrgbMain(int argc, const char **argv, const char *me, |
34 |
|
|
hestParm *hparm) { |
35 |
|
|
int pret; |
36 |
|
2 |
hestOpt *hopt = NULL; |
37 |
|
1 |
char *perr, *err; |
38 |
|
|
airArray *mop; |
39 |
|
|
|
40 |
|
|
tenEvecRGBParm *rgbp; |
41 |
|
1 |
Nrrd *nin, *nout; |
42 |
|
1 |
char *outS; |
43 |
|
|
|
44 |
|
1 |
mop = airMopNew(); |
45 |
|
1 |
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); |
46 |
|
|
|
47 |
|
1 |
rgbp = tenEvecRGBParmNew(); |
48 |
|
1 |
airMopAdd(mop, rgbp, AIR_CAST(airMopper, tenEvecRGBParmNix), airMopAlways); |
49 |
|
|
|
50 |
|
1 |
hestOptAdd(&hopt, "c", "evec index", airTypeUInt, 1, 1, &(rgbp->which), NULL, |
51 |
|
|
"which eigenvector will be colored. \"0\" for the " |
52 |
|
|
"principal, \"1\" for the middle, \"2\" for the minor"); |
53 |
|
2 |
hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &(rgbp->aniso), NULL, |
54 |
|
|
"Which anisotropy to use for modulating the saturation " |
55 |
|
|
"of the colors. " TEN_ANISO_DESC, |
56 |
|
1 |
NULL, tenAniso); |
57 |
|
1 |
hestOptAdd(&hopt, "t", "thresh", airTypeDouble, 1, 1, &(rgbp->confThresh), |
58 |
|
|
"0.5", "confidence threshold"); |
59 |
|
1 |
hestOptAdd(&hopt, "bg", "background", airTypeDouble, 1, 1, &(rgbp->bgGray), |
60 |
|
|
"0", "gray level to use for voxels who's confidence is zero "); |
61 |
|
1 |
hestOptAdd(&hopt, "gr", "gray", airTypeDouble, 1, 1, &(rgbp->isoGray), "0", |
62 |
|
|
"the gray level to desaturate towards as anisotropy " |
63 |
|
|
"decreases (while confidence remains 1.0)"); |
64 |
|
1 |
hestOptAdd(&hopt, "gam", "gamma", airTypeDouble, 1, 1, &(rgbp->gamma), "1", |
65 |
|
|
"gamma to use on color components"); |
66 |
|
1 |
hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", |
67 |
|
1 |
"input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); |
68 |
|
1 |
hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", |
69 |
|
|
"output image (floating point)"); |
70 |
|
|
|
71 |
|
1 |
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); |
72 |
✓✗ |
2 |
USAGE(_tend_evecrgbInfoL); |
73 |
|
|
PARSE(); |
74 |
|
|
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); |
75 |
|
|
|
76 |
|
|
nout = nrrdNew(); |
77 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
78 |
|
|
if (tenEvecRGB(nout, nin, rgbp)) { |
79 |
|
|
airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); |
80 |
|
|
fprintf(stderr, "%s: trouble doing colormapping:\n%s\n", me, err); |
81 |
|
|
airMopError(mop); return 1; |
82 |
|
|
} |
83 |
|
|
if (nrrdSave(outS, nout, NULL)) { |
84 |
|
|
airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); |
85 |
|
|
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); |
86 |
|
|
airMopError(mop); return 1; |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
airMopOkay(mop); |
90 |
|
|
return 0; |
91 |
|
1 |
} |
92 |
|
|
TEND_CMD(evecrgb, INFO); |