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 "unrrdu.h" |
25 |
|
|
#include "privateUnrrdu.h" |
26 |
|
|
|
27 |
|
|
#define INFO "Create image of 1-D value histogram" |
28 |
|
|
static const char *_unrrdu_dhistoInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". With \"-nolog\", this becomes a quick & dirty way of plotting a function.\n " |
31 |
|
|
"* Uses nrrdHistoDraw"); |
32 |
|
|
|
33 |
|
|
int |
34 |
|
|
unrrdu_dhistoMain(int argc, const char **argv, const char *me, |
35 |
|
|
hestParm *hparm) { |
36 |
|
2 |
hestOpt *opt = NULL; |
37 |
|
1 |
char *out, *err; |
38 |
|
1 |
Nrrd *nin, *nout; |
39 |
|
1 |
int pret, nolog, notick; |
40 |
|
1 |
unsigned int size; |
41 |
|
|
airArray *mop; |
42 |
|
1 |
double max; |
43 |
|
|
|
44 |
|
1 |
hestOptAdd(&opt, "h,height", "height", airTypeUInt, 1, 1, &size, NULL, |
45 |
|
|
"height of output image (horizontal size is determined by " |
46 |
|
|
"number of bins in input histogram)."); |
47 |
|
1 |
hestOptAdd(&opt, "nolog", NULL, airTypeInt, 0, 0, &nolog, NULL, |
48 |
|
|
"do not show the log-scaled histogram with decade tick-marks"); |
49 |
|
1 |
hestOptAdd(&opt, "notick", NULL, airTypeInt, 0, 0, ¬ick, NULL, |
50 |
|
|
"do not draw the log decade tick marks"); |
51 |
|
1 |
hestOptAdd(&opt, "max,maximum", "max # hits", airTypeDouble, 1, 1, |
52 |
|
|
&max, "nan", |
53 |
|
|
"constrain the top of the drawn histogram to be at this " |
54 |
|
|
"number of hits. This will either scale the drawn histogram " |
55 |
|
|
"downward or clip its top, depending on whether the given max " |
56 |
|
|
"is higher or lower than the actual maximum bin count. By " |
57 |
|
|
"not using this option (the default), the actual maximum bin " |
58 |
|
|
"count is used"); |
59 |
|
1 |
OPT_ADD_NIN(nin, "input nrrd"); |
60 |
|
1 |
OPT_ADD_NOUT(out, "output nrrd"); |
61 |
|
|
|
62 |
|
1 |
mop = airMopNew(); |
63 |
|
1 |
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); |
64 |
|
|
|
65 |
✓✗ |
2 |
USAGE(_unrrdu_dhistoInfoL); |
66 |
|
|
PARSE(); |
67 |
|
|
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); |
68 |
|
|
|
69 |
|
|
nout = nrrdNew(); |
70 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
71 |
|
|
|
72 |
|
|
if (nrrdHistoDraw(nout, nin, size, |
73 |
|
|
nolog ? AIR_FALSE : (notick ? 2 : AIR_TRUE), |
74 |
|
|
max)) { |
75 |
|
|
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); |
76 |
|
|
fprintf(stderr, "%s: error drawing histogram nrrd:\n%s", me, err); |
77 |
|
|
airMopError(mop); |
78 |
|
|
return 1; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
SAVE(out, nout, NULL); |
82 |
|
|
|
83 |
|
|
airMopOkay(mop); |
84 |
|
|
return 0; |
85 |
|
1 |
} |
86 |
|
|
|
87 |
|
|
UNRRDU_CMD(dhisto, INFO); |