File: | src/unrrdu/heq.c |
Location: | line 94, column 5 |
Description: | Function call argument is an uninitialized value |
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"Perform histogram equalization" "Perform histogram equalization" | |||||
28 | static const char *_unrrdu_heqInfoL = | |||||
29 | (INFO"Perform histogram equalization" | |||||
30 | ". If this seems to be doing nothing, try increasing the " | |||||
31 | "number of histograms bins by an order of magnitude or " | |||||
32 | "two (or more). Or, use \"unu gamma\" to warp the values " | |||||
33 | "in the direction you know they need to go. Either of " | |||||
34 | "these might work because extremely tall and narrow peaks " | |||||
35 | "in the equalization histogram will produce poor results.\n " | |||||
36 | "* Uses nrrdHistoEq"); | |||||
37 | ||||||
38 | int | |||||
39 | unrrdu_heqMain(int argc, const char **argv, const char *me, | |||||
40 | hestParm *hparm) { | |||||
41 | hestOpt *opt = NULL((void*)0); | |||||
42 | char *out, *err, *mapS; | |||||
43 | Nrrd *nin, *nout, *nmap; | |||||
| ||||||
44 | int smart, pret; | |||||
45 | unsigned int bins; | |||||
46 | airArray *mop; | |||||
47 | float amount; | |||||
48 | ||||||
49 | /* we want to facilitate saving out the mapping as a text file, | |||||
50 | but with the domain included */ | |||||
51 | /* this is commented out with the 8 Aug 2003 advent of nrrdDefGetenv | |||||
52 | nrrdDefWriteBareTable = AIR_FALSE; | |||||
53 | */ | |||||
54 | ||||||
55 | hestOptAdd(&opt, "b,bin", "bins", airTypeInt, 1, 1, &bins, NULL((void*)0), | |||||
56 | "# bins to use in histogram that is created in order to " | |||||
57 | "calculate the mapping that achieves the equalization."); | |||||
58 | hestOptAdd(&opt, "s,smart", "bins", airTypeInt, 0, 1, &smart, "0", | |||||
59 | "# bins in value histogram to ignore in calculating the mapping. " | |||||
60 | "Bins are ignored when they get more hits than other bins, and " | |||||
61 | "when the values that fall in them are constant. This is an " | |||||
62 | "effective way to prevent large regions of background value " | |||||
63 | "from distorting the equalization mapping."); | |||||
64 | hestOptAdd(&opt, "a,amount", "amount", airTypeFloat, 1, 1, &amount, "1.0", | |||||
65 | "extent to which the histogram equalizing mapping should be " | |||||
66 | "applied; 0.0: no change, 1.0: full equalization"); | |||||
67 | hestOptAdd(&opt, "m,map", "filename", airTypeString, 1, 1, &mapS, "", | |||||
68 | "The value mapping used to achieve histogram equalization is " | |||||
69 | "represented by a univariate regular map. By giving a filename " | |||||
70 | "here, that map can be saved out and applied to other nrrds " | |||||
71 | "with \"unu rmap\""); | |||||
72 | OPT_ADD_NIN(nin, "input nrrd")hestOptAdd(&opt, "i,input", "nin", airTypeOther, 1, 1, & (nin), "-", "input nrrd", ((void*)0), ((void*)0), nrrdHestNrrd ); | |||||
73 | OPT_ADD_NOUT(out, "output nrrd")hestOptAdd(&opt, "o,output", "nout", airTypeString, 1, 1, &(out), "-", "output nrrd"); | |||||
74 | ||||||
75 | mop = airMopNew(); | |||||
76 | airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); | |||||
77 | ||||||
78 | USAGE(_unrrdu_heqInfoL)if (!argc) { hestInfo(__stdoutp, me, (_unrrdu_heqInfoL), hparm ); hestUsage(__stdoutp, opt, me, hparm); hestGlossary(__stdoutp , opt, hparm); airMopError(mop); return 0; }; | |||||
79 | PARSE()if ((pret=hestParse(opt, argc, argv, &err, hparm))) { if ( 1 == pret || 2 == pret) { if (!(getenv("UNRRDU_QUIET_QUIT") && airEndsWith(err, "[nrrd] _nrrdRead: immediately hit EOF" "\n" ))) { fprintf(__stderrp, "%s: %s\n", me, err); free(err); hestUsage (__stderrp, opt, me, hparm); hestGlossary(__stderrp, opt, hparm ); } airMopError(mop); return 1; } else { exit(1); } }; | |||||
80 | airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); | |||||
81 | ||||||
82 | nout = nrrdNew(); | |||||
83 | airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); | |||||
84 | ||||||
85 | if (nrrdHistoEq(nout, nin, airStrlen(mapS) ? &nmap : NULL((void*)0), | |||||
86 | bins, smart, amount)) { | |||||
87 | airMopAdd(mop, err = biffGetDone(NRRDnrrdBiffKey), airFree, airMopAlways); | |||||
88 | fprintf(stderr__stderrp, "%s: trouble histogram equalizing:\n%s", me, err); | |||||
89 | airMopError(mop); | |||||
90 | return 1; | |||||
91 | } | |||||
92 | ||||||
93 | if (airStrlen(mapS)) { | |||||
94 | SAVE(mapS, nmap, NULL)if (nrrdSave((mapS), (nmap), (((void*)0)))) { airMopAdd(mop, err = biffGetDone(nrrdBiffKey), airFree, airMopAlways); fprintf( __stderrp, "%s: error saving nrrd to \"%s\":\n%s\n", me, (mapS ), err); airMopError(mop); return 1; }; | |||||
| ||||||
95 | } | |||||
96 | SAVE(out, nout, NULL)if (nrrdSave((out), (nout), (((void*)0)))) { airMopAdd(mop, err = biffGetDone(nrrdBiffKey), airFree, airMopAlways); fprintf( __stderrp, "%s: error saving nrrd to \"%s\":\n%s\n", me, (out ), err); airMopError(mop); return 1; }; | |||||
97 | ||||||
98 | airMopOkay(mop); | |||||
99 | return 0; | |||||
100 | } | |||||
101 | ||||||
102 | UNRRDU_CMD(heq, INFO)unrrduCmd unrrdu_heqCmd = { "heq", "Perform histogram equalization" , unrrdu_heqMain, 0 }; |