DGtal  1.5.beta
DGtal::CDLR< TSpace, TInputValue, TOutputValue > Class Template Reference

CDLR : Rotation with Discrete Line Reflections,. More...

#include <DGtal/images/bijectiveRotations/CDLR.h>

Public Member Functions

 CDLR (double ang, TOutputValue ptCenter, std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CDLR_naiverotation< TSpace >>> policy)
 
double angle () const
 
void set_angle (const double new_angle)
 
void dslSolver (double ang, TOutputValue ptCenter)
 
TOutputValue center () const
 
TOutputValue & center ()
 
TOutputValue rotate (const TInputValue &p) const
 
TOutputValue operator() (const TInputValue &p) const
 
template<typename Img >
Img rotateImage (Img img) const
 
std::string tostring () const
 
template<typename TImage >
TImage rotateImage (const TImage img) const
 

Protected Attributes

double my_angle
 The angle of rotation. More...
 
TOutputValue my_center
 The center of rotation. More...
 
CDLR_naiverotation< TSpace, TInputValue, TOutputValue > my_naive_rdlr_rotation
 
std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CDLR_naiverotation< TSpace > > > my_policy
 

Private Attributes

double a
 DSL specific variables, see Andres paper. More...
 
double b
 
double my_minAngle
 

Detailed Description

template<typename TSpace, typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
class DGtal::CDLR< TSpace, TInputValue, TOutputValue >

CDLR : Rotation with Discrete Line Reflections,.

Description of template struct CDLR

Template Parameters
TSpacea 2 dimensional space.
TInputValuetype of the input point e.g., TSpace::RealPoint.
TOutputValuetype of the output point e.g., TSpace::Point

Definition at line 53 of file CDLR.h.

Constructor & Destructor Documentation

◆ CDLR()

template<typename TSpace , typename TInputValue , typename TOutputValue >
DGtal::CDLR< TSpace, TInputValue, TOutputValue >::CDLR ( double  ang,
TOutputValue  ptCenter,
std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CDLR_naiverotation< TSpace >>>  policy 
)

CDLR Constructor.

Parameters
angthe angle given in radians.
ptCenterthe center of rotation.
policyeither Linf, L2, Lcontinuity, see Policy

Definition at line 115 of file CDLR.h.

115  :my_angle(ang),my_center(ptCenter),my_naive_rdlr_rotation(ang,ptCenter,0.),my_policy(policy){
116  dslSolver(ang,ptCenter);
117  }
CDLR_naiverotation< TSpace, TInputValue, TOutputValue > my_naive_rdlr_rotation
Definition: CDLR.h:104
std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CDLR_naiverotation< TSpace > > > my_policy
Definition: CDLR.h:105
void dslSolver(double ang, TOutputValue ptCenter)
Definition: CDLR.h:120
double my_angle
The angle of rotation.
Definition: CDLR.h:98
TOutputValue my_center
The center of rotation.
Definition: CDLR.h:100

References DGtal::CDLR< TSpace, TInputValue, TOutputValue >::dslSolver().

Member Function Documentation

◆ angle()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR< TSpace, TInputValue, TOutputValue >::angle ( ) const
inline
Returns
the angle of rotation.

Definition at line 64 of file CDLR.h.

64 {return my_angle;};

References DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_angle.

◆ center() [1/2]

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue& DGtal::CDLR< TSpace, TInputValue, TOutputValue >::center ( )
inline
Returns
a reference to the centre of rotation

Definition at line 81 of file CDLR.h.

81 {return my_center;};

References DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_center.

◆ center() [2/2]

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CDLR< TSpace, TInputValue, TOutputValue >::center ( ) const
inline
Returns
the centre of rotation

Definition at line 79 of file CDLR.h.

79 {return my_center;};

References DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_center.

◆ dslSolver()

template<typename TSpace , typename TInputValue , typename TOutputValue >
void DGtal::CDLR< TSpace, TInputValue, TOutputValue >::dslSolver ( double  ang,
TOutputValue  ptCenter 
)

initialisation function to find the composition of Discrete Line Reflection that minimises the sum of linf and lcontinuity

look for the pair of reflections that minimizes the Linf and Lcontinuity norm

Definition at line 120 of file CDLR.h.

120  {
121 
122  a = std::sin(ang/2.0);
123  b = std::cos(ang/2.0);
124 
125  TInputValue origin(0,0);
127 
128  double errorMinAlpha = 200.*200;
129  int N = 200;
130 
131  // create the domain
132  TOutputValue A(0,0);
133  TOutputValue B(1000,1000);
134  HyperRectDomain<TSpace> my_domain(A,B);
135 
136 
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);
143 
144  // compute both reflections and get both the Linf and Lcontinuity errors
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);
149  }
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];
154  }
155  }
156  }
double my_minAngle
Definition: CDLR.h:111
Aim: implements forward rigid transformation of point in the 2D integer space. Warring: This version ...
MessageStream error
Aim: Define a simple default functor that just returns its argument.

Referenced by DGtal::CDLR< TSpace, TInputValue, TOutputValue >::CDLR(), and DGtal::CDLR< TSpace, TInputValue, TOutputValue >::set_angle().

◆ operator()()

template<typename TSpace , typename TInputValue , typename TOutputValue >
TOutputValue DGtal::CDLR< TSpace, TInputValue, TOutputValue >::operator() ( const TInputValue &  p) const

Definition at line 171 of file CDLR.h.

◆ rotate()

template<typename TSpace , typename TInputValue , typename TOutputValue >
TOutputValue DGtal::CDLR< TSpace, TInputValue, TOutputValue >::rotate ( const TInputValue &  p) const
Parameters
pa lattice point
Returns
the rotation of the point p according to the current angle and center.

Definition at line 160 of file CDLR.h.

160  {
161  return this->operator()(p);
162  }
TOutputValue operator()(const TInputValue &p) const
Definition: CDLR.h:171

◆ rotateImage() [1/2]

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
template<typename TImage >
TImage DGtal::CDLR< TSpace, TInputValue, TOutputValue >::rotateImage ( const TImage  img) const

Definition at line 178 of file CDLR.h.

178  {
179  typedef typename TImage::Domain TDomain;
181  typedef std::pair < typename TSpace::Point, typename TSpace::Point > Bounds;
182 
183  typename TSpace::Point bottomLeft(-2,-2);
184  typename TSpace::Point topRight(2,2);
185  MyDomainTransformer domainTransformer ( *this );
186  Bounds bounds = domainTransformer ( img.domain() );
187  TDomain transformedDomain ( bounds.first+bottomLeft, bounds.second+topRight );
188  TImage rotatedImage ( transformedDomain );
189 
190  for (typename TDomain::ConstIterator it = img.domain().begin(); it != img.domain().end(); ++it )
191  {
192  rotatedImage.setValue((*this)(*it),img(*it));
193  }
194  return rotatedImage;
195  }
Aim: implements bounds of transformed domain.
MyDigitalSurface::ConstIterator ConstIterator
MyPointD Point
Definition: testClone2.cpp:383
HyperRectDomain< Space > Domain

◆ rotateImage() [2/2]

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
template<typename Img >
Img DGtal::CDLR< TSpace, TInputValue, TOutputValue >::rotateImage ( Img  img) const

◆ set_angle()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
void DGtal::CDLR< TSpace, TInputValue, TOutputValue >::set_angle ( const double  new_angle)
inline
Returns
set the angle of rotation and call the composition of reflections solver.

Definition at line 66 of file CDLR.h.

66  {
67  my_angle=new_angle;
68  my_naive_rdlr_rotation.set_angle(new_angle);
69  dslSolver(new_angle,my_center);
70  }

References DGtal::CDLR< TSpace, TInputValue, TOutputValue >::dslSolver(), DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_angle, DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_center, and DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_naive_rdlr_rotation.

◆ tostring()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
std::string DGtal::CDLR< TSpace, TInputValue, TOutputValue >::tostring ( ) const
inline

Definition at line 92 of file CDLR.h.

92  {
93  return {"CDLR"};
94  }

Field Documentation

◆ a

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR< TSpace, TInputValue, TOutputValue >::a
private

DSL specific variables, see Andres paper.

Definition at line 109 of file CDLR.h.

◆ b

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR< TSpace, TInputValue, TOutputValue >::b
private

Definition at line 110 of file CDLR.h.

◆ my_angle

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_angle
protected

◆ my_center

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_center
protected

◆ my_minAngle

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_minAngle
private

Definition at line 111 of file CDLR.h.

◆ my_naive_rdlr_rotation

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
CDLR_naiverotation<TSpace,TInputValue,TOutputValue> DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_naive_rdlr_rotation
protected

Definition at line 104 of file CDLR.h.

Referenced by DGtal::CDLR< TSpace, TInputValue, TOutputValue >::set_angle().

◆ my_policy

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
std::shared_ptr<Policy<TSpace,HyperRectDomain< TSpace>,CDLR_naiverotation<TSpace> > > DGtal::CDLR< TSpace, TInputValue, TOutputValue >::my_policy
protected

Definition at line 105 of file CDLR.h.


The documentation for this class was generated from the following file: