3
// fill in missing slices in a mask (e.g., lesion)
4
// Copyright (c) 1998-2002 by The VoxBo Development Team
6
// VoxBo is free software: you can redistribute it and/or modify it
7
// under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
11
// VoxBo is distributed in the hope that it will be useful, but
12
// WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with VoxBo. If not, see <http://www.gnu.org/licenses/>.
19
// For general information on VoxBo, including the latest complete
20
// source code and binary distributions, manual, and associated files,
21
// see the VoxBo home page at: http://www.voxbo.org/
23
// original version written by Dan Kimberg
31
#include "fillmask.hlp.h"
34
int getsampleslice(int start,int interval,int slice,int dimz);
37
main(int argc,char *argv[])
40
string infile,outfile;
41
int start,interval,sampleslice;
44
args.Transfer(argc-1,argv+1);
46
if (args.size() == 0) {
51
if (args.size() != 4) {
56
start=strtol(args[2]);
57
interval=strtol(args[3]);
58
printf("fillmasking %s to %s beginning slice %d and every %d...\n",args(0),args(1),start,interval);
63
mycube.ReadFile(infile);
64
if (!mycube.data_valid) {
65
printf("\nCouldn't make a valid cube out of %s.\n",infile.c_str());
68
// cout << mycube.GetFileType() << " " << t_img3d << endl;
70
for (int k=0; k<mycube.dimz; k++) {
71
sampleslice=getsampleslice(start,interval,k,mycube.dimz);
72
for (int i=0; i<mycube.dimx; i++) {
73
for (int j=0; j<mycube.dimy; j++) {
74
val=mycube.GetValue(i,j,sampleslice);
75
newcube.SetValue(i,j,k,val);
79
newcube.SetFileName(outfile);
80
newcube.SetFileFormat("img3d");
81
if (newcube.WriteFile())
82
printf("Error writing file %s.\n",outfile.c_str());
89
getsampleslice(int start,int interval,int slice,int dimz)
91
for (int i=0; i<dimz; i++) {
92
if (slice-i>=0 && slice-i <dimz)
93
if ((((slice-i)-start)%interval)==0)
95
if (slice+i>=0 && slice+i <dimz)
96
if ((((slice+i)-start)%interval)==0)
105
cout << boost::format(myhelp) % vbversion;