GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/unrrdu/tile.c Lines: 13 25 52.0 %
Date: 2017-05-26 Branches: 1 14 7.1 %

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 "unrrdu.h"
25
#include "privateUnrrdu.h"
26
27
#define INFO "Tile slices of one axis into two other axes"
28
static const char *_unrrdu_tileInfoL =
29
(INFO
30
 ". Tiling an array means splitting one axis into fast and slow parts, "
31
 "and then interleaving those parts into other (existing) axes by doing "
32
 "two axis merges, which combine an existing axis with part of the split "
33
 "axis.  This reduces the dimension by one.  The three axis arguments all "
34
 "identify axes in the input array as is.  This provides, for example, "
35
 "a simple way of viewing the 128 slices along the slow axis of a 3-D volume "
36
 "as a 16x8 tiled array of 2-D slices, as with \"-a 2 0 1 -s 16 8\".\n "
37
 "* Uses nrrdTile2D");
38
39
int
40
unrrdu_tileMain(int argc, const char **argv, const char *me,
41
                hestParm *hparm) {
42
2
  hestOpt *opt = NULL;
43
1
  char *out, *err;
44
1
  Nrrd *nin, *nout;
45
  int pret;
46
1
  size_t size[2];
47
1
  unsigned int axes[3];
48
  airArray *mop;
49
50
1
  hestOptAdd(&opt, "a,axis", "axSplit ax0 ax1", airTypeUInt, 3, 3, axes, NULL,
51
             "axSplit is divided and merged with ax0 and ax1");
52
1
  hestOptAdd(&opt, "s,size", "fast slow", airTypeSize_t, 2, 2, size, NULL,
53
             "fast and slow axis sizes to produce as result of splitting "
54
             "the axSplit axis.");
55
1
  OPT_ADD_NIN(nin, "input nrrd");
56
1
  OPT_ADD_NOUT(out, "output nrrd");
57
58
1
  mop = airMopNew();
59
1
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
60
61
2
  USAGE(_unrrdu_tileInfoL);
62
  PARSE();
63
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
64
65
  nout = nrrdNew();
66
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
67
68
  if (nrrdTile2D(nout, nin, axes[1], axes[2], axes[0], size[0], size[1])) {
69
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
70
    fprintf(stderr, "%s: error tiling nrrd:\n%s", me, err);
71
    airMopError(mop);
72
    return 1;
73
  }
74
75
  SAVE(out, nout, NULL);
76
77
  airMopOkay(mop);
78
  return 0;
79
1
}
80
81
UNRRDU_CMD(tile, INFO);