DGtalTools
1.3.beta
volumetric
volCrop.cpp
1
29
#include <iostream>
30
#include <DGtal/base/Common.h>
31
#include <DGtal/io/readers/VolReader.h>
32
#include <DGtal/io/writers/VolWriter.h>
33
#include <DGtal/helpers/StdDefs.h>
34
#include <DGtal/images/ImageContainerBySTLVector.h>
35
#include <DGtal/images/ConstImageAdapter.h>
36
37
#include "CLI11.hpp"
38
39
using namespace
std
;
40
using namespace
DGtal
;
41
using namespace
Z3i;
42
90
void
missingParam ( std::string param )
91
{
92
trace
.
error
() <<
" Parameter: "
<<param<<
" is required.."
;
93
trace
.
info
() <<std::endl;
94
exit ( 1 );
95
}
96
97
int
main
(
int
argc,
char
**argv)
98
{
99
100
// parse command line using CLI ----------------------------------------------
101
CLI::App app;
102
std::string inputFileName;
103
std::string outputFileName {
"output.vol"
};
104
int
xMin {0};
105
int
yMin {0};
106
int
zMin {0};
107
int
xMax;
108
int
yMax;
109
int
zMax;
110
111
app.description(
"Crops a 3D vol image from domain coordinates.\n Basic usage: \n \t volCrop --input <volFileName> --o <volOutputFileName> (both files can be independently in vol, pgm3D, p3d format)\nExample:\n volCrop --xMin 50 --yMin 50 --zMin 10 --xMax 150 --yMax 150 --zMax 50 -i ${DGtal}/examples/samples/lobster.vol -o croppedLobster.vol \n"
);
112
113
app.add_option(
"-i,--input,1"
, inputFileName,
"Input vol file."
)
114
->required()
115
->check(CLI::ExistingFile);
116
app.add_option(
"--output,-o,2"
, outputFileName,
"Output filename."
,
true
);
117
118
app.add_option(
"--xMin"
,xMin,
"x coordinate of lower point."
,
true
);
119
app.add_option(
"--yMin"
,yMin,
"y coordinate of lower point."
,
true
);
120
app.add_option(
"--zMin"
,zMin,
"z coordinate of lower point."
,
true
);
121
122
app.add_option(
"--xMax"
,xMax,
"x coordinate of upper point."
)
123
->required();
124
app.add_option(
"--yMax"
,yMax,
"y coordinate of upper point."
)
125
->required();
126
app.add_option(
"--zMax"
,zMax,
"z coordinate of upper point."
)
127
->required();
128
129
app.get_formatter()->column_width(40);
130
CLI11_PARSE(app, argc, argv);
131
// END parse command line using CLI ----------------------------------------------
132
133
Z3i::Point
ptLow( xMin, yMin, zMin);
134
Z3i::Point
ptMax(xMax , yMax, zMax);
135
136
trace
.
beginBlock
(
"Loading file"
);
137
typedef
ImageContainerBySTLVector<Z3i::Domain, unsigned char>
MyImageC;
138
MyImageC imageC =
VolReader< MyImageC >::importVol
( inputFileName );
139
functors::Identity
df;
140
141
typedef
ConstImageAdapter<MyImageC, Domain, functors::Identity, MyImageC::Value, functors::Identity >
ConstImageAdapterForSubImage;
142
Domain
subDomain(ptLow, ptMax);
143
ConstImageAdapterForSubImage subImage(imageC, subDomain, df, df);
144
trace
.
endBlock
();
145
146
trace
.
beginBlock
(
"Exporting..."
);
147
bool
res =
VolWriter< ConstImageAdapterForSubImage>::exportVol
(outputFileName, subImage);
148
trace
.
endBlock
();
149
if
(res)
return
0;
else
return
1;
150
}
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::VolWriter
std
STL namespace.
DGtal::Trace::endBlock
double endBlock()
PointVector< dim, Integer >
main
int main(int argc, char **argv)
Definition:
3dHeightMapViewer.cpp:206
DGtal::functors::Identity
DGtal::VolReader
DGtal
DGtal::trace
Trace trace(traceWriterTerm)
DGtal::Trace::info
std::ostream & info()
DGtal::ConstImageAdapter
DGtal::Trace::error
std::ostream & error()
DGtal::ImageContainerBySTLVector
Domain
typename Self::Domain Domain
Companion project associated to
DGtal
; Generated on Wed Jun 2 2021 15:55:56 for DGtalTools by
1.8.14