DGtal  1.5.beta
ErrorBijectiveRotation.h
1 
17 #pragma once
18 
28 #if defined(ErrorBijectiveRotation_RECURSES)
29 #error Recursive header files inclusion detected in ErrorBijectiveRotation.h
30 #else // defined(ErrorBijectiveRotation_RECURSES)
32 #define ErrorBijectiveRotation_RECURSES
33 
34 #if !defined ErrorBijectiveRotation_h
36 #define ErrorBijectiveRotation_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>
45 
47  typedef std::vector<std::vector<typename TSpace::RealPoint>> VectorField;
48 
49  protected:
50  TBijectiveReflections normalVectors;
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 
65  for (typename TDomain::ConstIterator it = set2dContour.begin(); it != set2dContour.end(); ++it ) {
66  std::vector<typename TSpace::RealPoint> pixelError;
67  typename TSpace::Point p = *it;
68 
69  typename TSpace::Point preflections = normalVectors(p-my_center)+my_center;
70  typename TSpace::RealPoint protation = targetRotation(p);
71 
72  // compute the error field
73  typename TSpace::RealPoint error = protation - preflections ;
74  pixelError.push_back(error);
75 
76  // compute the eucliean rotation of the neighbors of p
77  if(continuityVecField) {
78  // for the 8-Neighbor, compute the rotation
79  for(int veci = -1 ; veci <2 ; ++veci) {
80  for(int vecj = -1 ; vecj<2 ; ++vecj) {
81  if(veci!=0 || vecj!=0){
82  typename TSpace::RealPoint vecij_rot = originCenteredRotation({static_cast<double>(veci),static_cast<double>(vecj)});
83  typename TSpace::RealPoint neigh_rot = protation+vecij_rot;
84  pixelError.push_back(neigh_rot-preflections);
85  }
86 
87  }
88  }
89 
90  }
91 
92 
93  outVecField.push_back(pixelError);
94  }
95  return outVecField;
96  }
97  };
98 }
99 
100 #endif //ErrorBijectiveRotation
101 #undef ErrorBijectiveRotation_RECURSES
102 #endif // else defined(ErrorBijectiveRotation_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