DGtal  1.5.beta
ErrorVectorField.h
1 
17 #pragma once
18 
28 #if defined(ERRORVECTORFIELD_RECURSES)
29 #error Recursive header files inclusion detected in ErrorVectorField.h
30 #else // defined(ERRORVECTORFIELD_RECURSES)
32 #define ERRORVECTORFIELD_RECURSES
33 
34 #if !defined ERRORVECTORFIELD_h
36 #define ERRORVECTORFIELD_h
37 
39 // Inclusions
40 #include <DGtal/images/RigidTransformation2D.h>
41 
42 namespace DGtal{
43  template<typename TSpace, typename TDomain, typename TBijectiveReflections, typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
44  struct ErrorVectorField{
45 
47  typedef std::vector<std::vector<typename TSpace::RealPoint>> VectorField;
48 
49  protected:
50  TBijectiveReflections normalVectors;
51  typename TSpace::Point my_center;
54 
55  public:
56  ErrorVectorField(const TBijectiveReflections& reflections,const double theta,const typename TSpace::Point center):normalVectors(reflections),targetRotation(center,theta,{0,0}),my_center(center),originCenteredRotation({0,0},theta,{0,0})
57  {}
58 
62  VectorField getOutputVectorFieldFromContour(const TDomain& set2dContour, bool continuityVecField =false ){
63  VectorField outVecField;
64  // std::cout << "DSL output vector error : normalVectors "<<normalVectors.my_startingAngle<<std::endl;
65  // std::cout << "DSL output vector error : rotation angle "<<normalVectors.my_angle<<std::endl;
66  // std::cout << "input test point = "<<*(set2dContour.begin()+30)<<std::endl;
67  // std::cout << "output double reflections = "<<normalVectors(*(set2dContour.begin()+30)-my_center)+my_center<<std::endl;
68  // std::cout << "output rotation = "<<targetRotation(*(set2dContour.begin()+30))<<std::endl;
69 
70  for (typename TDomain::ConstIterator it = set2dContour.begin(); it != set2dContour.end(); ++it ) {
71  std::vector<typename TSpace::RealPoint> pixelError;
72  typename TSpace::Point p = *it;
73 
74  typename TSpace::Point preflections = normalVectors(p-my_center)+my_center;
75  typename TSpace::RealPoint protation = targetRotation(p);
76 
77  // compute the error field
78  typename TSpace::RealPoint error = protation - preflections ;
79  pixelError.push_back(error);
80 
81  // compute the eucliean rotation of the neighbors of p
82  if(continuityVecField) {
83  // for the 8-Neighbor, compute the rotation
84  for(int veci = -1 ; veci <2 ; ++veci) {
85  for(int vecj = -1 ; vecj<2 ; ++vecj) {
86  if(veci!=0 || vecj!=0){
87  typename TSpace::RealPoint vecij_rot = originCenteredRotation({static_cast<double>(veci),static_cast<double>(vecj)});
88  typename TSpace::RealPoint neigh_rot = protation+vecij_rot;
89  pixelError.push_back(neigh_rot-preflections);
90  }
91 
92  }
93  }
94 
95  }
96 
97 
98  outVecField.push_back(pixelError);
99  }
100 
101  return outVecField;
102  }
103 
104  };
105 }
106 
107 
108 #endif //ERRORVECTORFIELD
109 #undef ERRORVECTORFIELD_RECURSES
110 #endif // else defined(ERRORVECTORFIELD_RECURSES)
Aim: implements forward rigid transformation of point in the 2D integer space. Warring: This version ...
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
ErrorVectorField(const TBijectiveReflections &reflections, const double theta, const typename TSpace::Point center)
std::vector< std::vector< typename TSpace::RealPoint > > VectorField
VectorField getOutputVectorFieldFromContour(const TDomain &set2dContour, bool continuityVecField=false)
functors::ForwardRigidTransformation2D< TSpace, TInputValue, typename TSpace::RealPoint, functors::Identity > RealRotation
TBijectiveReflections normalVectors
MyPointD Point
Definition: testClone2.cpp:383
PointVector< 3, double > RealPoint