28 #include <DGtal/base/Common.h>
29 #include <DGtal/io/readers/VolReader.h>
30 #include <DGtal/io/writers/VolWriter.h>
31 #include <DGtal/helpers/StdDefs.h>
32 #include <DGtal/images/Image.h>
33 #include <DGtal/images/ImageContainerBySTLVector.h>
38 using namespace DGtal;
83 void missingParam ( std::string param )
85 trace.error() <<
" Parameter: "<<param<<
" is required..";
86 trace.info() <<std::endl;
91 int main(
int argc,
char**argv)
96 std::string inputFileName;
97 std::string outputFileName {
"result.vol"};
98 bool addInside {
false};
100 app.description(
"Add a border of one voxel with value 0 around a vol file.\n \tvolAddBorder --input <volFileName> --o <volOutputFileName>\n Example: \n \t volAddBorder -i $DGtal/examples/samples/Al.100.vol -o Al.100border.vol");
102 app.add_option(
"-i,--input,1", inputFileName,
"Input vol file." )
104 ->check(CLI::ExistingFile);
105 app.add_flag(
"--inside", addInside ,
"Sets zero value to domain boundary voxels without changing the domain extent.");
106 app.add_option(
"--output,-o,2", outputFileName,
"Output filename.");
108 app.get_formatter()->column_width(40);
109 CLI11_PARSE(app, argc, argv);
113 typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;
115 MyImageC imageC = VolReader< MyImageC >::importVol ( inputFileName );
116 Z3i::Domain rDom ( imageC.domain().lowerBound() - Vector().
diagonal(addInside ? 0: 1),
117 imageC.domain().upperBound() + Vector().
diagonal(addInside ? 0: 1));
118 MyImageC outputImage(rDom);
119 Z3i::Domain iDom ( imageC.domain().lowerBound() + Vector().
diagonal( 1),
120 imageC.domain().upperBound() - Vector().
diagonal( 1));
123 for(MyImageC::Domain::ConstIterator it = imageC.domain().begin(),
124 itend = imageC.domain().end(); it != itend; ++it){
126 outputImage.setValue( *it , imageC(*it));
130 if (!iDom.isInside(*it)){
131 imageC.setValue( *it , 0);
138 res= VolWriter< MyImageC>::exportVol(outputFileName, outputImage);
141 res= VolWriter< MyImageC>::exportVol(outputFileName, imageC);
143 if (res)
return 0;
else return 1;
DGtal::LinearOperator< Calculus, dim, duality, dim, duality > diagonal(const DGtal::KForm< Calculus, dim, duality > &kform)