28 #if defined(CDLR_RECURSES)
29 #error Recursive header files inclusion detected in CDLR.h
38 #include "DGtal/base/Common.h"
39 #include <DGtal/images/RigidTransformation2D.h>
40 #include "CDLR_naiverotation.h"
41 #include "DigitizedReflection.h"
52 template <
typename TSpace,
typename TInputValue =
typename TSpace::Po
int,
typename TOutputValue =
typename TSpace::Po
int>
74 void dslSolver(
double ang, TOutputValue ptCenter);
86 TOutputValue
rotate(
const TInputValue& p )
const;
87 TOutputValue
operator()(
const TInputValue& p )
const;
89 template<
typename Img>
114 template<
typename TSpace,
typename TInputValue,
typename TOutputValue>
115 CDLR<TSpace,TInputValue,TOutputValue>::CDLR(
const double ang,
const TOutputValue ptCenter, std::shared_ptr<
Policy<TSpace,
HyperRectDomain< TSpace>,
CDLR_naiverotation<TSpace>>> policy ):my_angle(ang),my_center(ptCenter),my_naive_rdlr_rotation(ang,ptCenter,0.),my_policy(policy){
119 template<
typename TSpace,
typename TInputValue,
typename TOutputValue>
122 a = std::sin(ang/2.0);
123 b = std::cos(ang/2.0);
125 TInputValue origin(0,0);
128 double errorMinAlpha = 200.*200;
133 TOutputValue B(1000,1000);
138 std::vector<double> mix_errors;
139 std::vector<double> angles;
140 for(
int k=0;k<N;++k){
141 double alphaCourant = -M_PI_2 + (k*M_PI_2)/N;
142 angles.push_back(alphaCourant);
145 std::vector<double> linf_per_image;
146 my_naive_rdlr_rotation.set_startingAngle(alphaCourant);
147 double error = my_policy->evaluate(my_domain,my_naive_rdlr_rotation,my_angle,my_center);
148 mix_errors.push_back(error);
150 for(
int idxImages = 0 ; idxImages < mix_errors.size() ; idxImages++) {
151 if(mix_errors[idxImages] < errorMinAlpha) {
152 errorMinAlpha = mix_errors[idxImages];
153 my_minAngle = angles[idxImages];
159 template<
typename TSpace,
typename TInputValue,
typename TOutputValue>
161 return this->operator()(p);
170 template<
typename TSpace,
typename TInputValue,
typename TOutputValue>
172 return my_naive_rdlr_rotation.reflect(my_minAngle+(my_angle),my_center,my_naive_rdlr_rotation.reflect(my_minAngle,my_center,p-my_center))+my_center;
176 template<
typename TSpace,
typename TInputValue,
typename TOutputValue>
177 template<
typename TImage>
181 typedef std::pair < typename TSpace::Point, typename TSpace::Point > Bounds;
185 MyDomainTransformer domainTransformer ( *
this );
186 Bounds bounds = domainTransformer ( img.domain() );
187 TDomain transformedDomain ( bounds.first+bottomLeft, bounds.second+topRight );
188 TImage rotatedImage ( transformedDomain );
192 rotatedImage.setValue((*
this)(*it),img(*it));
CDLR : Rotation with Discrete Line Reflections,.
CDLR_naiverotation< TSpace, TInputValue, TOutputValue > my_naive_rdlr_rotation
TOutputValue rotate(const TInputValue &p) const
std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CDLR_naiverotation< TSpace > > > my_policy
TOutputValue operator()(const TInputValue &p) const
double a
DSL specific variables, see Andres paper.
Img rotateImage(Img img) const
CDLR(double ang, TOutputValue ptCenter, std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CDLR_naiverotation< TSpace >>> policy)
TOutputValue center() const
void dslSolver(double ang, TOutputValue ptCenter)
void set_angle(const double new_angle)
std::string tostring() const
double my_angle
The angle of rotation.
TOutputValue my_center
The center of rotation.
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: implements bounds of transformed domain.
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Define a simple default functor that just returns its argument.
HyperRectDomain< Space > Domain