36 #if defined(SegmentComputerEstimators_RECURSES) 37 #error Recursive header files inclusion detected in SegmentComputerEstimators.h 38 #else // defined(SegmentComputerEstimators_RECURSES) 40 #define SegmentComputerEstimators_RECURSES 42 #if !defined SegmentComputerEstimators_h 44 #define SegmentComputerEstimators_h 49 #include "DGtal/base/Common.h" 50 #include "DGtal/helpers/StdDefs.h" 51 #include "boost/utility.hpp" 83 template <
typename TSegmentComputer,
typename Functor,
123 return (mySCPtr != 0);
140 void init(
const double ,
const ConstIterator& itb,
const ConstIterator& ite)
159 Quantity
eval(
const ConstIterator& )
const 174 template <
typename OutputIterator>
175 OutputIterator
eval(
const ConstIterator& itb,
const ConstIterator& ite,
176 OutputIterator result)
const 183 ConstIterator it = itb;
215 template <
typename TSegmentComputer,
typename Functor,
258 : myH( 0.0 ), myBegin(), myEnd(), mySCPtr(0), myFunctor()
266 : myH( other.myH ), myBegin( other.myBegin ), myEnd( other.myEnd ),
267 mySCPtr( other.mySCPtr ), myFunctor( other.myFunctor )
297 return (myH > 0)&&(mySCPtr != 0);
311 void init(
const double h,
const ConstIterator& itb,
const ConstIterator& ite)
333 Quantity
eval(
const ConstIterator& )
const 348 template <
typename OutputIterator>
349 OutputIterator
eval(
const ConstIterator& itb,
const ConstIterator& ite,
350 OutputIterator result)
const 357 ConstIterator it = itb;
388 template <
typename TSegmentComputer,
typename Functor,
428 return (mySCPtr != 0);
444 void init(
const double ,
const ConstIterator& itb,
const ConstIterator& ite)
464 Quantity
eval(
const ConstIterator& it)
const 479 template <
typename OutputIterator>
480 OutputIterator
eval(
const ConstIterator& itb,
const ConstIterator& ite,
481 OutputIterator result)
const 488 ConstIterator it = itb;
519 template <
typename TSegmentComputer,
typename Functor,
562 : myH( 0.0 ), myBegin(), myEnd(), mySCPtr(0), myFunctor()
570 : myH( other.myH ), myBegin( other.myBegin ), myEnd( other.myEnd ),
571 mySCPtr( other.mySCPtr ), myFunctor( other.myFunctor )
601 return (myH > 0)&&(mySCPtr != 0);
615 void init(
const double h,
const ConstIterator& itb,
const ConstIterator& ite)
638 Quantity
eval(
const ConstIterator& it)
const 653 template <
typename OutputIterator>
654 OutputIterator
eval(
const ConstIterator& itb,
const ConstIterator& ite,
655 OutputIterator result)
const 662 ConstIterator it = itb;
665 *result++ =
myFunctor( it, *mySCPtr, myH );
701 template<
typename DSS>
702 Value operator() (
const DSS& aDSS)
const 705 ::castToDouble(aDSS.a());
707 ::castToDouble(aDSS.b());
709 return std::atan2(a,b);
734 template<
typename DSS>
735 Value operator() (
const DSS& aDSS)
const 742 double norm = v.norm(RealVector::L_2);
751 template<
typename DSS>
766 Value operator() (
const DSS& aDSS)
const 768 return Value(aDSS.b(), aDSS.a());
783 template<
bool isCCW = true>
802 template<
typename DCA>
803 Value operator() (
const DCA& aDCA,
const double& aH = 1.0)
const 805 if ( aDCA.isStraight() )
808 return ( aDCA.getSeparatingCircle().getCurvature() / aH );
817 template<
typename DCA>
818 Value operator() (
const DCA& aDCA,
const Value& aH = 1.0)
const 820 if ( aDCA.isStraight() )
823 return - ( aDCA.getSeparatingCircle().getCurvature() / aH );
849 template<
typename DCA>
851 const DCA& aDCA)
const 853 typedef typename DCA::Pair Pair;
855 typedef typename Point::Coordinate Coordinate;
857 if ( !aDCA.isStraight() )
861 aDCA.getSeparatingCircle().getParameters(c0, c1, r);
864 Point i = pair.first;
865 Point o = pair.second;
872 double n = std::sqrt(v0*v0 + v1*v1);
873 return Value( v0/n, v1/n );
879 aDCA.getStabbingLineComputerPtr()->getParameters(a, b, c);
881 double n = std::sqrt(a*a + b*b);
882 return Value( a/n, b/n );
911 template<
typename DCA>
913 const DCA& aDCA)
const 916 Value normal = f(it, aDCA);
917 return Value( normal[1], normal[0] );
929 typedef std::pair<double,double>
Value;
947 template<
typename DCA>
949 const DCA& aDCA,
const double& aH)
const 951 typedef typename DCA::Pair Pair;
953 typedef typename Point::Coordinate Coordinate;
955 if ( !aDCA.isStraight() )
959 aDCA.getSeparatingCircle().getParameters(c0, c1, r);
962 Point i = pair.first;
963 Point o = pair.second;
967 double distI = std::sqrt( distI0*distI0 + distI1*distI1 ) - r;
970 double distO = std::sqrt( distO0*distO0 + distO1*distO1 ) - r;
971 return Value( distI*aH, distO*aH );
977 aDCA.getStabbingLineComputerPtr()->getParameters(a, b, c);
979 double n = std::sqrt(a*a + b*b);
982 Point i = pair.first;
983 Point o = pair.second;
987 double distI = rI / n;
990 double distO = rO / n;
991 return Value( distI*aH, distO*aH );
1009 template <
typename DSSComputer>
1038 template <
typename DSSComputer>
1068 template <
typename DSSComputer>
1106 template <
typename DCAComputer,
bool isCCW = true>
1109 detail::CurvatureFromDCA<isCCW> >
1136 template <
typename DCAComputer>
1139 detail::NormalVectorFromDCA>
1166 template <
typename DCAComputer>
1169 detail::TangentVectorFromDCA>
1197 template <
typename DCAComputer>
1200 detail::DistanceFromDCA>
1239 template<
typename DSS>
1240 Value operator() (
const DSS& aDSS)
const 1244 Vector v = ( *aDSS.begin() - *boost::prior(aDSS.end()) );
1245 Value l = v.norm(Vector::L_2);
1247 return 1/( (l*l)/8 + 0.5 );
1267 template<
typename DSS>
1268 Value operator() (
const DSS& aDSS)
const 1272 Vector v = ( *aDSS.begin() - *boost::prior(aDSS.end()) );
1273 Value l = v.norm(Vector::L_2);
1275 Vector t( aDSS.b(), aDSS.a() );
1276 Value w = 1.0 / v.norm(Vector::L_2);
1278 return 1.0/( (l*l)/(8*w) + w/2 );
1300 template <
typename DSSComputer,
typename Functor = detail::CurvatureFromDSSLength >
1344 : myH( 0.0 ), myBegin(), myEnd(), mySCPtr(0), myFunctor()
1352 : myH( other.myH ), myBegin( other.myBegin ), myEnd( other.myEnd ),
1353 mySCPtr( other.mySCPtr ), myFunctor( other.myFunctor )
1366 myEnd = other.
myEnd;
1383 return (myH > 0)&&(mySCPtr != 0);
1395 void init(
const double h,
const ConstIterator& itb,
const ConstIterator& ite)
1407 Quantity
eval(
const ConstIterator& )
1412 typedef typename DSSComputer::Integer Integer;
1422 ConstIterator back = mySCPtr->
begin();
1423 ConstIterator front = mySCPtr->end();
1424 bool isConnectedAtBack =
isNotEmpty(myBegin, back)
1426 bool isConnectedAtFront =
isNotEmpty(front, myEnd)
1430 if (isConnectedAtBack) {
1431 if (isConnectedAtFront) {
1436 Integer mu = mySCPtr->mu();
1437 Integer omega = mySCPtr->omega();
1440 if ( (mySCPtr->remainder(*back)<=mu-1)&&
1441 (mySCPtr->remainder(*front)<=mu-1) ) {
1443 }
else if ( (mySCPtr->remainder(*back)>=mu+omega)&&
1444 (mySCPtr->remainder(*front)>=mu+omega) ) {
1453 Integer mu = mySCPtr->mu();
1454 Integer omega = mySCPtr->omega();
1457 if ( (mySCPtr->remainder(*back)<=mu-1) ) {
1459 }
else if ( (mySCPtr->remainder(*back)>=mu+omega) ) {
1464 }
else if (isConnectedAtFront) {
1467 Integer mu = mySCPtr->mu();
1468 Integer omega = mySCPtr->omega();
1471 if ( (mySCPtr->remainder(*front)<=mu-1) ) {
1473 }
else if ( (mySCPtr->remainder(*front)>=mu+omega) ) {
1492 template <
typename OutputIterator>
1493 OutputIterator
eval(
const ConstIterator& itb,
const ConstIterator& ite,
1494 OutputIterator result)
1501 ConstIterator it = itb;
1504 *result++ =
eval( it );
1506 }
while (it != ite);
1551 template <
typename DSSComputer>
1588 template <
typename DSSComputer>
1613 #endif // !defined SegmentComputerEstimators_h 1615 #undef SegmentComputerEstimators_RECURSES 1616 #endif // else defined(SegmentComputerEstimators_RECURSES)
DSSComputer SegmentComputer
SegmentComputer::ConstIterator ConstIterator
PosDepScaleIndepSCEstimator()
Quantity eval(const ConstIterator &it) const
PosDepScaleDepSCEstimator & operator=(const PosDepScaleDepSCEstimator &other)
~CurvatureFromDSSBaseEstimator()
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
detail::PosIndepScaleIndepSCEstimator< DSSComputer, detail::NormalizedTangentVectorFromDSS > Super
MyDigitalSurface::ConstIterator ConstIterator
CurvatureFromDSSBaseEstimator()
static double castToDouble(const T &aT)
PosIndepScaleDepSCEstimator & operator=(const PosIndepScaleDepSCEstimator &other)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
SegmentComputer::ConstIterator ConstIterator
void init(const double, const ConstIterator &itb, const ConstIterator &ite)
detail::PosDepScaleDepSCEstimator< DCAComputer, detail::DistanceFromDCA > Super
SegmentComputer::ConstIterator ConstIterator
TSegmentComputer SegmentComputer
PosIndepScaleDepSCEstimator(const PosIndepScaleDepSCEstimator &other)
const SegmentComputer * mySCPtr
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
TangentVectorFromDSSEstimator(const TangentVectorFromDSSEstimator &other)
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
detail::PosIndepScaleIndepSCEstimator< DSSComputer, detail::TangentAngleFromDSS > Super
PosIndepScaleIndepSCEstimator()
Aim: Defines a unary functor, which associates arguments to results.
CurvatureFromDSSEstimator(const CurvatureFromDSSEstimator &other)
CurvatureFromDCAEstimator()
detail::CurvatureFromDSSBaseEstimator< DSSComputer, detail::CurvatureFromDSSLengthAndWidth > Super
DSSComputer::ConstIterator ConstIterator
Quantity eval(const ConstIterator &it) const
Quantity eval(const ConstIterator &) const
bool isNotEmpty(const IC &itb, const IC &ite, IteratorType)
TangentFromDSSEstimator()
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
SegmentComputer::ConstIterator ConstIterator
detail::PosIndepScaleDepSCEstimator< DCAComputer, detail::CurvatureFromDCA< isCCW > > Super
PointVector< 2, double > Value
Aim: The traits class for all models of Cinteger.
CurvatureFromDCAEstimator(const CurvatureFromDCAEstimator &other)
~PosDepScaleDepSCEstimator()
CurvatureFromDSSEstimator()
TSegmentComputer SegmentComputer
TangentFromDSSEstimator(const TangentFromDSSEstimator &other)
DistanceFromDCAEstimator(const DistanceFromDCAEstimator &other)
ConstIterator begin() const
TangentFromDCAEstimator()
CurvatureFromDSSLengthEstimator(const CurvatureFromDSSLengthEstimator &other)
DGtal is the top-level namespace which contains all DGtal functions and types.
detail::PosIndepScaleIndepSCEstimator< DSSComputer, detail::TangentVectorFromDSS< DSSComputer > > Super
TangentVectorFromDSSEstimator()
const SegmentComputer * mySCPtr
TangentAngleFromDSSEstimator(const TangentAngleFromDSSEstimator &other)
detail::PosDepScaleIndepSCEstimator< DCAComputer, detail::NormalVectorFromDCA > Super
const SegmentComputer * mySCPtr
~PosIndepScaleDepSCEstimator()
void init(const double, const ConstIterator &itb, const ConstIterator &ite)
void attach(const SegmentComputer &aSC)
std::pair< double, double > Value
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result)
CurvatureFromDSSLengthEstimator()
void attach(const SegmentComputer &aSC)
PointVector< 2, double > Value
Quantity eval(const ConstIterator &)
Quantity eval(const ConstIterator &) const
detail::PosDepScaleIndepSCEstimator< DCAComputer, detail::TangentVectorFromDCA > Super
PosDepScaleDepSCEstimator(const PosDepScaleDepSCEstimator &other)
FreemanChain< int >::Vector Vector
TangentAngleFromDSSEstimator()
PosDepScaleDepSCEstimator()
TSegmentComputer SegmentComputer
void attach(const SegmentComputer &aSC)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
const SegmentComputer * mySCPtr
NormalFromDCAEstimator(const NormalFromDCAEstimator &other)
void attach(const SegmentComputer &aSC)
PosIndepScaleDepSCEstimator()
DistanceFromDCAEstimator()
DGtal::PointVector< 2, double > RealVector
const SegmentComputer * mySCPtr
detail::CurvatureFromDSSBaseEstimator< DSSComputer, detail::CurvatureFromDSSLength > Super
CurvatureFromDSSBaseEstimator & operator=(const CurvatureFromDSSBaseEstimator &other)
TangentFromDCAEstimator(const TangentFromDCAEstimator &other)
TSegmentComputer SegmentComputer
void attach(const SegmentComputer &aSC)
CurvatureFromDSSBaseEstimator(const CurvatureFromDSSBaseEstimator &other)