DGtal  1.5.beta
CBDR_naiverotation.h
1 
17 #pragma once
18 
28 #if defined(CBDRNAIVEROTATION_RECURSES)
29 #error Recursive header files inclusion detected in CBDR_naiverotation.h
30 #else // defined(CBDRNAIVEROTATION_RECURSES)
32 #define CBDRNAIVEROTATION_RECURSES
33 
34 #if !defined CBDRNAIVEROTATION_h
36 #define CBDRNAIVEROTATION_h
37 
39 // Inclusions
40 #include "DigitizedReflection.h"
41 #include "GAVector.h"
42 namespace DGtal {
44  template<typename TSpace, typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
47 
48  std::vector<DigitizedReflection> bijectiveNormalVectors;
49 
50  CBDR_naiverotation(const std::vector<DigitizedReflection>& bijectiveReflections={} ):bijectiveNormalVectors(bijectiveReflections){ }
51 
52  explicit CBDR_naiverotation(const std::vector<GAVector<TSpace>>& bijectiveGAvec ){
53  bijectiveNormalVectors.resize(bijectiveGAvec.size());
54  std::transform(bijectiveGAvec.begin(), bijectiveGAvec.end(), bijectiveNormalVectors.begin(),
55  [](const GAVector<TSpace>& p) { return DigitizedReflection(p); });
56  }
57 
62  TOutputValue operator()( const TInputValue & aInput ) const
63  {
64  if(bijectiveNormalVectors.size()<=0){
65  return (TOutputValue)aInput;
66  }
67  int i =0;
68  DigitizedReflection firstReflection(bijectiveNormalVectors[i]);
69  TOutputValue resultat = firstReflection(aInput);
70 
71  i+=1;
72  for(; i < bijectiveNormalVectors.size(); ++i)
73  {
74  DigitizedReflection currentReflection(bijectiveNormalVectors[i]);
75  resultat = currentReflection(resultat);
76  }
77  return resultat;
78  }
79 
80  template<typename TImage>
81  TImage rotateImage(TImage img) const {
82  typedef typename TImage::Domain TDomain;
84  typedef std::pair < typename TSpace::Point, typename TSpace::Point > Bounds;
85 
86  MyDomainTransformer domainTransformer ( *this );
87  Bounds bounds = domainTransformer ( img.domain() );
88  TDomain transformedDomain ( bounds.first, bounds.second );
89  TImage rotatedImage ( transformedDomain );
90 
91  for (typename TDomain::ConstIterator it = img.domain().begin(); it != img.domain().end(); ++it )
92  {
93  rotatedImage.setValue((*this)(*it),img(*it));
94  }
95  return rotatedImage;
96  }
97 
98  };
99 }
100 
101 
102 #endif //CBDRNAIVEROTATION
103 #undef CBDRNAIVEROTATION_RECURSES
104 #endif // else defined(CBDRNAIVEROTATION_RECURSES)
Aim: implements bounds of transformed domain.
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
vec since the parameters are the vectors of digitized reflections
TOutputValue operator()(const TInputValue &aInput) const
std::vector< DigitizedReflection > bijectiveNormalVectors
TImage rotateImage(TImage img) const
CBDR_naiverotation(const std::vector< DigitizedReflection > &bijectiveReflections={})
CBDR_naiverotation(const std::vector< GAVector< TSpace >> &bijectiveGAvec)
Reflection< TSpace, TInputValue > DigitizedReflection
HyperRectDomain< Space > Domain