31 #include "DGtal/base/Common.h"
32 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/io/readers/GenericReader.h"
35 #include "DGtal/io/writers/GenericWriter.h"
36 #include "DGtal/images/ConstImageAdapter.h"
37 #include "DGtal/kernel/BasicPointFunctors.h"
39 #include <boost/program_options/options_description.hpp>
40 #include <boost/program_options/parsers.hpp>
41 #include <boost/program_options/variables_map.hpp>
46 using namespace DGtal;
98 namespace po = boost::program_options;
101 int main(
int argc,
char** argv )
111 po::options_description general_opt(
"Allowed options are: ");
112 general_opt.add_options()
113 (
"help,h",
"display this message")
114 (
"input,i", po::value<std::string >(),
"input volumetric file (.vol, .longvol, .pgm3d) " )
115 (
"output,o", po::value<std::string>(),
"the new volumetric file (.vol, .longvol, .pgm3d) " )
116 (
"gridSize,g", po::value<std::vector<double> >()->multitoken(),
"size_x size_y size_z : the grid size of the re sampling ");
120 po::variables_map vm;
122 po::store(po::parse_command_line(argc, argv, general_opt), vm);
123 }
catch(
const std::exception& ex){
125 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
131 if( !parseOK || vm.count(
"help") || !vm.count(
"gridSize") || ! vm.count(
"input")||! vm.count(
"output") )
133 std::cout <<
"Usage: " << argv[0] <<
" [input-files] [output-file]\n"
134 <<
"Re sample a 3D volumetric image (.vol, .longvol, .pgm3d) with a given grid size. \n"
135 << general_opt <<
"\n";
136 std::cout <<
"Example:\n to re sample an image with scale x,y,z = 0.98, 0.98, 5.0, you can do: \n"
137 <<
"volResSample -i image3d.vol -g 1 1 2 -o imageReSampled.vol \n" << endl;
145 std::vector< double > aGridSizeReSample = vm[
"gridSize"].as<std::vector<double > >();
146 if(aGridSizeReSample.size()!=3){
147 trace.
error() <<
"The grid size should contains 3 elements" << std::endl;
151 std::string inputFileName = vm[
"input"].as<std::string>();
152 std::string outputFileName = vm[
"output"].as<std::string>();
155 trace.
info()<<
"Importing volume file : " << inputFileName<<
" ... " ;
161 DGtal::functors::BasicDomainSubSampler< HyperRectDomain<SpaceND<3, int> >,
163 aGridSizeReSample, shiftVector3D);
166 SamplerImageAdapter sampledImage ( input3dImage, reSampler.getSubSampledDomain(), reSampler, aFunctor );
Trace trace(traceWriterTerm)
const Domain & domain() const