32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/io/readers/PointListReader.h"
40 #include "DGtal/geometry/curves/FreemanChain.h"
44 #include <boost/program_options/options_description.hpp>
45 #include <boost/program_options/parsers.hpp>
46 #include <boost/program_options/variables_map.hpp>
52 using namespace DGtal;
99 namespace po = boost::program_options;
102 int main(
int argc,
char** argv )
105 po::options_description general_opt(
"Allowed options are: ");
106 general_opt.add_options()
107 (
"help,h",
"display this message")
108 (
"input,i", po::value<std::string>(),
"Input freeman chain file name.")
109 (
"info",
"adds some info as comments at the beginning of the file.")
110 (
"oneLine,o",
" output the digital contour in one line like: X0 Y0 X1 Y1 ... XN YN");
118 po::variables_map vm;
120 po::store(po::parse_command_line(argc, argv, general_opt), vm);
121 }
catch(
const std::exception& ex){
123 trace.
info()<<
"Error checking program options: "<< ex.what()<< std::endl;
127 if(!parseOK||vm.count(
"help")||argc<=1 || (!(vm.count(
"input")) ) )
129 trace.
info()<<
"Transform freeman chain into a Sequence of Discrete Points. Result is given to std output. " <<std::endl <<
"Basic usage: "<<std::endl
130 <<
"\t freeman2sdp [input] > out.sdp "<<std::endl
131 << general_opt <<
"\n";
133 <<
"freeman2sdp -i ${DGtal}/tests/samples/contourS.fc > contourS.sdp \n";
138 bool oneline = vm.count(
"oneLine");
139 if( vm.count(
"input") ){
140 std::string fileName = vm[
"input"].as<std::string>();
143 for(
unsigned int i=0; i< vectFcs.size(); i++){
144 bool isClosed = vectFcs.at(i).isClosed();
145 std::cout <<
"# grid curve " << i+1 <<
"/" << vectFcs.size()
146 << ( (isClosed)?
" closed":
" open" ) << std::endl;
147 if ( vm.count(
"info"))
148 std::cout <<
"# SDP contour" << i+1<<
"/" << vectFcs.size() <<
" "
149 <<
"# size=" << vectFcs.at(i).size() << std::endl;
150 std::vector<Z2i::Point> vectPts;
152 for(
unsigned int k=0; k < vectPts.size(); k++){
153 std::cout << vectPts.at(k)[0] <<
" "<< vectPts.at(k)[1] ;
155 std::cout << std::endl;
162 std::cout << std::endl;
Trace trace(traceWriterTerm)
static void getContourPoints(const FreemanChain &fc, std::vector< Point > &aVContour)