GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/ten/tendSten.c Lines: 15 29 51.7 %
Date: 2017-05-26 Branches: 1 22 4.5 %

Line Branch Exec Source
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 "Calculate structure tensors from a scalar field"
28
static const char *_tend_stenInfoL =
29
  (INFO
30
   ".  Not a diffusion tensor, but it is symmetric and positive-definate.");
31
32
int
33
tend_stenMain(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
1
  int iScale, dScale, dsmp;
41
1
  Nrrd *nin, *nout;
42
1
  char *outS;
43
44
1
  hestOptAdd(&hopt, "ds", "diff. scale", airTypeInt, 1, 1, &dScale, "1",
45
             "differentiation scale, in pixels: the radius of the "
46
             "kernel used for differentation to compute gradient vectors");
47
1
  hestOptAdd(&hopt, "is", "int. scale", airTypeInt, 1, 1, &iScale, "2",
48
             "integration scale, in pixels: the radius of the "
49
             "kernel used for blurring outer products of gradients "
50
             "in order compute structure tensors");
51
1
  hestOptAdd(&hopt, "df", "downsample factor", airTypeInt, 1, 1, &dsmp, "1",
52
             "the factor by which to downsample when creating volume of "
53
             "structure tensors");
54
1
  hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-",
55
             "input scalar volume",
56
1
             NULL, NULL, nrrdHestNrrd);
57
1
  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
58
             "output filename");
59
60
1
  mop = airMopNew();
61
1
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
62
2
  USAGE(_tend_stenInfoL);
63
  PARSE();
64
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
65
66
  nout = nrrdNew();
67
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
68
69
  if (gageStructureTensor(nout, nin, dScale, iScale, dsmp)) {
70
    airMopAdd(mop, err=biffGetDone(GAGE), airFree, airMopAlways);
71
    fprintf(stderr, "%s: trouble calculating structure tensors:\n%s\n",
72
            me, err);
73
    airMopError(mop); return 1;
74
  }
75
76
  if (nrrdSave(outS, nout, NULL)) {
77
    airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
78
    fprintf(stderr, "%s: trouble writing:\n%s\n", me, err);
79
    airMopError(mop); return 1;
80
  }
81
82
  airMopOkay(mop);
83
  return 0;
84
1
}
85
TEND_CMD(sten, INFO);
86
87