DGtal  1.5.beta
RBC.h
1 
18 #pragma once
19 
29 #if defined(RBC_RECURSES)
30 #error Recursive header files inclusion detected in RBC.h
31 #else // defined(RBC_RECURSES)
33 #define RBC_RECURSES
34 
35 #if !defined RBC_h
37 #define RBC_h
38 
39 #include <iostream>
40 #include <vector>
41 #include <map>
42 #include <chrono>
43 #include "RBC_vec.h"
44 
45 namespace DGtal {
46 
54  template<typename TSpace, typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
55  struct RBC {
58 
65  RBC( const RBC_vec<TSpace,TInputValue,TOutputValue>& aRot, const double angle, const TOutputValue center )
66  : rot( aRot ),my_angle(angle),my_center(center) {}
67 
69  template<typename TImage>
70  TImage rotateImage( const TImage& img) const
71  {
72  typedef typename TImage::Domain TDomain;
74  typedef std::pair < typename TSpace::Point, typename TSpace::Point > Bounds;
75 
76  typename TSpace::Point bottomLeft(-1,-1);
77  typename TSpace::Point topRight(1,1);
78 
79  MyDomainTransformer domainTransformer ( rot );
80  Bounds bounds = domainTransformer ( img.domain() );
81  TDomain transformedDomain ( bounds.first+bottomLeft, bounds.second+topRight );
82  TImage rotatedImage ( transformedDomain );
83 
84 
85 
86  // for ( auto r = 1; r < rot.size(); r++ )
87  // rotateCircle( img, rotatedImage, my_center, my_angle, r );
88 
89  for (typename TDomain::ConstIterator it = img.domain().begin(); it != img.domain().end(); ++it ) {
90  rotatedImage.setValue((*this).rot.operator()(*it),img(*it));
91  }
92  return rotatedImage;
93  }
94 
95  TOutputValue operator()( const TInputValue & aInput ) const
96  {
97  return (*this).rot.operator()(aInput);
98  }
99 
100  std::string tostring() const {
101  return {"RBC"};
102  }
103 
104  void set_angle(const double newAngle) {
105  my_angle=newAngle;
106  rot.setAngle()= newAngle;
107  }
108 
110  inline TOutputValue center() const{return my_center;}
111 
112 
113  double my_angle;
114  TOutputValue my_center;
115 
116  };
117 
118 
119 }
120 
121 #endif //RBC
122 
123 #undef RBC_RECURSES
124 #endif // else defined(RBC_RECURSES)
Aim: implements bounds of transformed domain.
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
RBC : Bijective Rotation through Circles.
Definition: RBC_vec.h:56
std::vector< TOutputValue > Circle
Definition: RBC_vec.h:57
RBC : Bijective Rotation through Circles.
Definition: RBC.h:55
TOutputValue operator()(const TInputValue &aInput) const
Definition: RBC.h:95
std::string tostring() const
Definition: RBC.h:100
void set_angle(const double newAngle)
Definition: RBC.h:104
TOutputValue center() const
Definition: RBC.h:110
RBC_vec< TSpace, TInputValue, TOutputValue >::Circle Circle
Definition: RBC.h:57
TOutputValue my_center
Definition: RBC.h:114
RBC_vec< TSpace, TInputValue, TOutputValue > rot
Definition: RBC.h:56
RBC(const RBC_vec< TSpace, TInputValue, TOutputValue > &aRot, const double angle, const TOutputValue center)
Definition: RBC.h:65
double my_angle
Definition: RBC.h:113
TImage rotateImage(const TImage &img) const
Rotates the whole image Image circle by circle.
Definition: RBC.h:70
MyPointD Point
Definition: testClone2.cpp:383
HyperRectDomain< Space > Domain