From 7e6d9cfdf1b3feae9f8537f987b9a847805d4035 Mon Sep 17 00:00:00 2001 From: Kerautret Date: Sat, 4 Feb 2017 17:34:38 +0100 Subject: [PATCH 1/5] add sdp as input for tangentBC --- ChangeLog.md | 3 ++- estimators/tangentBC.cpp | 42 ++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 8fcf62aa..a142009e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -24,7 +24,8 @@ - *estimators*: - 2dlocalEstimators: add an option to export the generated contour. (Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/285)) - + - tangentBC: add anoption to read sdp points as input. + (Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/286)) # DGtalTools 0.9.2 diff --git a/estimators/tangentBC.cpp b/estimators/tangentBC.cpp index e68c5961..8a9ee3aa 100644 --- a/estimators/tangentBC.cpp +++ b/estimators/tangentBC.cpp @@ -39,6 +39,7 @@ #include "DGtal/base/Common.h" #include "DGtal/helpers/StdDefs.h" +#include "DGtal/io/readers/PointListReader.h" //Grid curve #include "DGtal/geometry/curves/FreemanChain.h" @@ -65,7 +66,7 @@ namespace po = boost::program_options; @b Allowed @b options @b are : @code -h [ --help ] display this message - -i [ --input ] arg input FreemanChain file name + -i [ --input ] arg input file name: FreemanChain (.fc) or a sequence of discrete points (.sdp). -s [ --GridStep ] arg (=1) Grid step @endcode @@ -105,7 +106,7 @@ int main( int argc, char** argv ) po::options_description general_opt("Allowed options are: "); general_opt.add_options() ("help,h", "display this message") - ("input,i", po::value(), "input FreemanChain file name") + ("input,i", po::value(), "input file name: FreemanChain (.fc) or a sequence of discrete points (.sdp).") ("GridStep,step", po::value()->default_value(1.0), "Grid step"); @@ -135,7 +136,8 @@ int main( int argc, char** argv ) if(vm.count("input")){ std::string fileName = vm["input"].as(); - + std::string extension = fileName.substr( fileName.find_last_of(".") + 1 ); + bool isSDP = extension == "sdp"; typedef Z2i::Space Space; typedef Space::Point Point; typedef PointVector<2, double> RealPoint; @@ -144,18 +146,30 @@ int main( int argc, char** argv ) typedef std::vector< Point > Storage; typedef Storage::const_iterator ConstIteratorOnPoints; - std::vector< FreemanChain > vectFcs = - PointListReader< Point >:: getFreemanChainsFromFile (fileName); - - for(unsigned int i=0; i vectFcs; + if(!isSDP) + { + vectFcs = + PointListReader< Point >:: getFreemanChainsFromFile (fileName); + } + for(unsigned int i=0; i::getPointsFromFile(fileName); + Z2i::Point pf =vectPts[0]; + Z2i::Point pl =vectPts[vectPts.size()-1]; + isClosed = (pf[0]-pl[0])+(pf[1]-pl[1]) <= 1; + } + // Binomial std::cout << "# Curvature estimation from binomial convolution" << std::endl; typedef BinomialConvolver MyBinomialConvolver; From 2137dc0ee5dd0fbf6f4e06d86052cb8a2c2cc5cd Mon Sep 17 00:00:00 2001 From: Kerautret Date: Sat, 4 Feb 2017 17:36:23 +0100 Subject: [PATCH 2/5] number PR --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index a142009e..77d83d82 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -25,7 +25,7 @@ - 2dlocalEstimators: add an option to export the generated contour. (Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/285)) - tangentBC: add anoption to read sdp points as input. - (Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/286)) + (Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/288)) # DGtalTools 0.9.2 From f0bac5276262beb7f4b14442beb9c7029e44814e Mon Sep 17 00:00:00 2001 From: Kerautret Date: Wed, 8 Feb 2017 13:53:34 +0100 Subject: [PATCH 3/5] ajout option coord points --- estimators/tangentBC.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/estimators/tangentBC.cpp b/estimators/tangentBC.cpp index 8a9ee3aa..f244fc28 100644 --- a/estimators/tangentBC.cpp +++ b/estimators/tangentBC.cpp @@ -188,7 +188,7 @@ int main( int argc, char** argv ) tangents.begin() ); // Output - std::cout << "# id tangent.x tangent.y angle(atan2(y,x))" << std::endl; + std::cout << "# id tangent.x tangent.y angle(atan2(y,x)) x y" << std::endl; unsigned int j = 0; for ( ConstIteratorOnPoints it = vectPts.begin(), it_end = vectPts.end(); @@ -198,7 +198,7 @@ int main( int argc, char** argv ) double y = tangents[ j ][ 1 ]; std::cout << j << std::setprecision( 15 ) << " " << x << " " << y - << " " << atan2( y, x ) + << " " << atan2( y, x ) << " " << (*it)[0] << (*it)[1] << std::endl; } From a53dafc84e6570ef091c45a55296c9760dea58b5 Mon Sep 17 00:00:00 2001 From: Kerautret Date: Wed, 8 Feb 2017 13:54:48 +0100 Subject: [PATCH 4/5] typo and add export contour coord as output --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 991185c9..db13f4e9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,7 +26,7 @@ - *estimators*: - 2dlocalEstimators: add an option to export the generated contour. (Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/285)) - - tangentBC: add anoption to read sdp points as input. + - tangentBC: add an option to read sdp points as input. (Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/288)) From fe1fda9b09022e60bceb17148e8b598a545df2fa Mon Sep 17 00:00:00 2001 From: Kerautret Date: Wed, 8 Feb 2017 14:05:50 +0100 Subject: [PATCH 5/5] white space in output --- estimators/tangentBC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/estimators/tangentBC.cpp b/estimators/tangentBC.cpp index f244fc28..c3e38d1b 100644 --- a/estimators/tangentBC.cpp +++ b/estimators/tangentBC.cpp @@ -198,7 +198,7 @@ int main( int argc, char** argv ) double y = tangents[ j ][ 1 ]; std::cout << j << std::setprecision( 15 ) << " " << x << " " << y - << " " << atan2( y, x ) << " " << (*it)[0] << (*it)[1] + << " " << atan2( y, x ) << " " << (*it)[0] << " " << (*it)[1] << std::endl; }