34 #include "DGtal/base/Common.h"
36 #include "DGtal/shapes/ShapeFactory.h"
37 #include "DGtal/shapes/Shapes.h"
38 #include "DGtal/helpers/StdDefs.h"
39 #include "DGtal/topology/helpers/Surfaces.h"
42 #include "DGtal/geometry/curves/FreemanChain.h"
43 #include "DGtal/geometry/curves/GridCurve.h"
46 #include "DGtal/geometry/curves/BinomialConvolver.h"
49 #include <boost/program_options/options_description.hpp>
50 #include <boost/program_options/parsers.hpp>
51 #include <boost/program_options/variables_map.hpp>
57 using namespace DGtal;
105 namespace po = boost::program_options;
108 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 FreemanChain file name")
115 (
"GridStep,step", po::value<double>()->default_value(1.0),
"Grid step");
119 po::variables_map vm;
121 po::store(po::parse_command_line(argc, argv, general_opt), vm);
122 }
catch(
const std::exception& ex){
124 trace.
info()<<
"Error checking program options: "<< ex.what()<< std::endl;
127 if(!parseOK || vm.count(
"help")||argc<=1 || (!(vm.count(
"input"))) )
129 trace.
info()<<
"Curvature using a binomial convolver " <<std::endl <<
"Basic usage: "<<std::endl
130 <<
"\t curvatureBC [options] --input <fileName> "<<std::endl
131 << general_opt <<
"\n";
136 double h = vm[
"GridStep"].as<
double>();
140 if(vm.count(
"input")){
141 std::string fileName = vm[
"input"].as<std::string>();
144 typedef Space::Point
Point;
145 typedef Space::Integer
Integer;
147 typedef std::vector< Point > Storage;
148 typedef Storage::const_iterator ConstIteratorOnPoints;
153 for(
unsigned int i=0; i<vectFcs.size(); i++){
155 bool isClosed = vectFcs.at(i).isClosed();
156 std::cout <<
"# grid curve " << i+1 <<
"/" << vectFcs.size() <<
" "
157 << ( (isClosed)?
"closed":
"open" ) << std::endl;
163 std::cout <<
"# Curvature estimation from binomial convolution" << std::endl;
165 std::cout <<
"# mask size = " <<
166 MyBinomialConvolver::suggestedSize( h, vectPts.begin(), vectPts.end() ) << std::endl;
171 BCCurvatureEstimator.
init( h, vectPts.begin(), vectPts.end(), isClosed );
173 std::vector <double> curvatures( vectPts.size() );
174 BCCurvatureEstimator.
eval( vectPts.begin(), vectPts.end(), curvatures.begin() );
177 std::cout <<
"# id curvature" << std::endl;
179 for ( ConstIteratorOnPoints it = vectPts.begin(), it_end = vectPts.end();
180 it != it_end; ++it, ++j ) {
181 std::cout << j << std::setprecision( 15 )
182 <<
" " << curvatures[ j ] << std::endl;
void init(const double h, const ConstIterator &itb, const ConstIterator &ite, const bool isClosed=true)
SpaceND< 2, Integer > Space
Trace trace(traceWriterTerm)
typename Self::Point Point
Quantity eval(const ConstIterator &it)
static void getContourPoints(const FreemanChain &fc, std::vector< Point > &aVContour)