DGtal  1.5.beta
DGtal::CBDR< TSpace, TInputValue, TOutputValue > Struct Template Reference

CBDR : Composition of Bijective Digitized Reflections,. More...

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

Public Types

typedef Reflection< TSpace, TInputValue > DigitizedReflection
 
typedef std::vector< std::pair< std::vector< GAVector< TSpace > >, GAVector< TSpace > > > BijectiveSearchTree
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 Checking concepts. More...
 
 BOOST_STATIC_ASSERT ((TSpace::dimension==2))
 
 BOOST_STATIC_ASSERT ((TOutputValue::dimension==2))
 
 BOOST_STATIC_ASSERT ((TInputValue::dimension==2))
 
 CBDR (const double theta, const typename TSpace::Point center, const size_t nbreflect, const size_t km, std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CBDR_naiverotation< TSpace >>> policy, const bool precompute=true, const bool fast=true)
 
std::shared_ptr< CBDR_naiverotation< TSpace > > initCBDRVec ()
 
void set_angle (const double newAngle)
 
void setPolicy (const std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CBDR_naiverotation< TSpace >>> &newPolicy)
 
TOutputValue operator() (const TInputValue &aInput) const
 
template<typename TImage >
TImage rotateImage (TImage img) const
 
std::string tostring () const
 
TOutputValue center () const
 

Data Fields

NBijectiveGenerator< TSpace, TInputValue > nbijectiveGen
 
std::vector< BijectiveSearchTreevecBijectiveSearchTree
 
HyperRectDomain< TSpace > my_domain
 
size_t kmax
 
size_t nbReflections
 
bool usePrecomputedTable
 
bool useFastTable
 
int N
 
double my_angle
 number of sample rotation angle More...
 
TOutputValue my_center
 
std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CBDR_naiverotation< TSpace > > > my_policy
 
std::vector< CBDR_naiverotation< TSpace, TInputValue > > fastCBDRTable
 
std::shared_ptr< CBDR_naiverotation< TSpace > > my_cbdr
 

Private Member Functions

std::vector< CBDR_naiverotation< TSpace, TInputValue > > loadFastOptimisedTable (const std::string &fastTableName)
 load fast optimised table in case the table is found More...
 
void initcbdr_loadBijectiveReflectionSearchTree (const HyperRectDomain< TSpace > &my_domain)
 
std::vector< CBDR_naiverotation< TSpace, TInputValue > > initFastPrecomputationTable (const HyperRectDomain< TSpace > &points, NBijectiveGenerator< TSpace > &nbijectiveVectors, std::vector< BijectiveSearchTree > &vecBijectiveSearchTree)
 

Private Attributes

bool fastTableFound
 

Detailed Description

template<typename TSpace, typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
struct DGtal::CBDR< TSpace, TInputValue, TOutputValue >

CBDR : Composition of Bijective Digitized Reflections,.

Description of template struct CBDR

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 57 of file CBDR.h.

Member Typedef Documentation

◆ BijectiveSearchTree

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
typedef std::vector<std::pair<std::vector<GAVector<TSpace> >,GAVector<TSpace> > > DGtal::CBDR< TSpace, TInputValue, TOutputValue >::BijectiveSearchTree

Definition at line 66 of file CBDR.h.

◆ DigitizedReflection

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
typedef Reflection<TSpace,TInputValue> DGtal::CBDR< TSpace, TInputValue, TOutputValue >::DigitizedReflection

Definition at line 65 of file CBDR.h.

Constructor & Destructor Documentation

◆ CBDR()

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
DGtal::CBDR< TSpace, TInputValue, TOutputValue >::CBDR ( const double  theta,
const typename TSpace::Point  center,
const size_t  nbreflect,
const size_t  km,
std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CBDR_naiverotation< TSpace >>>  policy,
const bool  precompute = true,
const bool  fast = true 
)
inline

CBDR Constructor.

Parameters
thetathe angle given in radians.
centerthe center of rotation.
nbreflectthe number of composition of bjijective reflections applied (2,4)
kmconditions the number of bijective reflection normal vectors
policyeither Linf, L2, Lcontinuity, see Policy
precomputeuse precomputed table of the sorted bijective composition of bijective digitized reflections
fastuse the table that stores for each angle the composition that minimised the Linf metric distorsion

Definition at line 79 of file CBDR.h.

80  :nbijectiveGen(km),my_domain(typename TSpace::Point(0,0),typename TSpace::Point(100,100)),my_angle(theta),my_center(center),nbReflections(nbreflect),kmax(km),my_policy(policy),
82  }
void precompute()
TOutputValue center() const
Definition: CBDR.h:145
TOutputValue my_center
Definition: CBDR.h:158
bool useFastTable
Definition: CBDR.h:155
size_t nbReflections
Definition: CBDR.h:153
std::shared_ptr< CBDR_naiverotation< TSpace > > initCBDRVec()
Definition: CBDR.h:88
HyperRectDomain< TSpace > my_domain
Definition: CBDR.h:150
NBijectiveGenerator< TSpace, TInputValue > nbijectiveGen
Definition: CBDR.h:148
std::shared_ptr< CBDR_naiverotation< TSpace > > my_cbdr
Definition: CBDR.h:161
bool usePrecomputedTable
Definition: CBDR.h:154
double my_angle
number of sample rotation angle
Definition: CBDR.h:157
int N
Definition: CBDR.h:156
std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CBDR_naiverotation< TSpace > > > my_policy
Definition: CBDR.h:159
size_t kmax
Definition: CBDR.h:152
MyPointD Point
Definition: testClone2.cpp:383

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
DGtal::CBDR< TSpace, TInputValue, TOutputValue >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )

Checking concepts.

◆ BOOST_STATIC_ASSERT() [1/3]

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
DGtal::CBDR< TSpace, TInputValue, TOutputValue >::BOOST_STATIC_ASSERT ( (TInputValue::dimension==2)  )

◆ BOOST_STATIC_ASSERT() [2/3]

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
DGtal::CBDR< TSpace, TInputValue, TOutputValue >::BOOST_STATIC_ASSERT ( (TOutputValue::dimension==2)  )

◆ BOOST_STATIC_ASSERT() [3/3]

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
DGtal::CBDR< TSpace, TInputValue, TOutputValue >::BOOST_STATIC_ASSERT ( (TSpace::dimension==2)  )

◆ center()

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

Definition at line 145 of file CBDR.h.

145 {return my_center;}

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

◆ initcbdr_loadBijectiveReflectionSearchTree()

template<typename TSpace , typename TInputValue , typename TOutputValue >
void DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initcbdr_loadBijectiveReflectionSearchTree ( const HyperRectDomain< TSpace > &  my_domain)
private

Definition at line 188 of file CBDR.h.

188  {
189 
190  for(size_t nbReflec = 2 ; nbReflec <= nbReflections ; nbReflec+=2) {
191  BijectiveSearchTree vecBijNormals;
192  std::string tableName("CBDRTable_"+std::to_string(nbReflec)+"_"+std::to_string(kmax)+".txt");
193  // check that the file exists when usePrecomputedTable is set to true
194  if(usePrecomputedTable ) {
195  struct stat buffer;
196  bool exists = (stat (tableName.c_str(), &buffer) == 0);
197  if(!exists) {
198  usePrecomputedTable=false;
199  }
200  }
201 
203  std::cout << "loading precomputed table ..."<<std::endl;
204  vecBijNormals = functions::loadBijectiveRotationTable<TSpace,TInputValue>(tableName,nbReflec,kmax);
205  } else {
206  std::cout << "does not use precomputed table"<<std::endl;
207  auto tableIntVecBijNormals = nbijectiveGen.n_bijectiveReflections_get_NormalVectorsAngles(nbReflec);
208  nbijectiveGen.writeBijectiveVectors("CBDRTable_"+std::to_string(nbReflec)+"_"+std::to_string(kmax)+".txt",tableIntVecBijNormals );
209  vecBijNormals = nbijectiveGen.vecBijNormals_index_2_GAVector(tableIntVecBijNormals);
210  }
211  vecBijectiveSearchTree.push_back(vecBijNormals);
212  }
213 
214  }
std::vector< std::pair< std::vector< GAVector< TSpace > >, GAVector< TSpace > > > BijectiveSearchTree
Definition: CBDR.h:66
std::vector< BijectiveSearchTree > vecBijectiveSearchTree
Definition: CBDR.h:149

Referenced by DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initCBDRVec().

◆ initCBDRVec()

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
std::shared_ptr<CBDR_naiverotation<TSpace> > DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initCBDRVec ( )
inline

solver part

solver part

Definition at line 88 of file CBDR.h.

88  {
89  if(useFastTable) {
90  std::cout << "use fast table"<<std::endl;
91  std::string fastTableName=("CBDROptimisedTable_"+std::to_string(nbReflections)+"_"+std::to_string(kmax)+".txt");
92  struct stat buffer;
93  fastTableFound = (stat (fastTableName.c_str(), &buffer) == 0);
94  if(fastTableFound) {
96  }else {
99  }
101  CBDRFastSolver<TSpace,HyperRectDomain<TSpace>> cbdrFastSolver(fastCBDRTable,my_angle,my_center,kmax);
102  return std::make_shared<CBDR_naiverotation<TSpace>>(cbdrFastSolver.solve());
103  }else{
106  CBDRSolver<TSpace,HyperRectDomain<TSpace>> cbdrSolver(my_angle, my_center,kmax,N);
107  return std::make_shared<CBDR_naiverotation<TSpace>>(cbdrSolver.solve(my_domain,nbijectiveGen, vecBijectiveSearchTree,*my_policy));
108  }
109  }
bool fastTableFound
Definition: CBDR.h:165
std::vector< CBDR_naiverotation< TSpace, TInputValue > > fastCBDRTable
Definition: CBDR.h:160
void initcbdr_loadBijectiveReflectionSearchTree(const HyperRectDomain< TSpace > &my_domain)
Definition: CBDR.h:188
std::vector< CBDR_naiverotation< TSpace, TInputValue > > initFastPrecomputationTable(const HyperRectDomain< TSpace > &points, NBijectiveGenerator< TSpace > &nbijectiveVectors, std::vector< BijectiveSearchTree > &vecBijectiveSearchTree)
Definition: CBDR.h:218
std::vector< CBDR_naiverotation< TSpace, TInputValue > > loadFastOptimisedTable(const std::string &fastTableName)
load fast optimised table in case the table is found
Definition: CBDR.h:178

References DGtal::CBDR< TSpace, TInputValue, TOutputValue >::fastCBDRTable, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::fastTableFound, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initcbdr_loadBijectiveReflectionSearchTree(), DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initFastPrecomputationTable(), DGtal::CBDR< TSpace, TInputValue, TOutputValue >::kmax, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::loadFastOptimisedTable(), DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_angle, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_center, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_domain, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_policy, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::N, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::nbijectiveGen, DGtal::CBDR< TSpace, TInputValue, TOutputValue >::nbReflections, DGtal::CBDRFastSolver< TSpace, TDomain >::solve(), DGtal::CBDRSolver< TSpace, TDomain >::solve(), DGtal::CBDR< TSpace, TInputValue, TOutputValue >::useFastTable, and DGtal::CBDR< TSpace, TInputValue, TOutputValue >::vecBijectiveSearchTree.

Referenced by DGtal::CBDR< TSpace, TInputValue, TOutputValue >::setPolicy().

◆ initFastPrecomputationTable()

template<typename TSpace , typename TInputValue , typename TOutputValue >
std::vector< CBDR_naiverotation< TSpace, TInputValue > > DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initFastPrecomputationTable ( const HyperRectDomain< TSpace > &  points,
NBijectiveGenerator< TSpace > &  nbijectiveVectors,
std::vector< BijectiveSearchTree > &  vecBijectiveSearchTree 
)
private

Definition at line 217 of file CBDR.h.

219  {
220  std::vector<CBDR_naiverotation<TSpace, TInputValue>> fastCBDRtab;
221  auto Linf = std::make_shared<DGtal::LinfPolicy<TSpace,DGtal::HyperRectDomain<TSpace>,DGtal::CBDR_naiverotation<TSpace>>>();
222  auto LContinuity = std::make_shared<DGtal::LcontinuityPolicy<TSpace,DGtal::HyperRectDomain<TSpace>,DGtal::CBDR_naiverotation<TSpace>>>();
223 
224  std::string tablefilename ="CBDROptimisedTable_"+std::to_string(nbReflections)+"_"+std::to_string(kmax)+".txt";
225  std::ofstream file(tablefilename);
226  for(int alpha = 0 ; alpha < 91; ++alpha) {
227  double currentAngle = (alpha * M_PI) / 180.0;
228  CBDRSolver<TSpace,HyperRectDomain<TSpace>> cbdrsolv(currentAngle, my_center,kmax,N);
229  std::vector<Reflection<TSpace>> bestReflections =cbdrsolv.solve(points,nbijectiveVectors,
231 
232  CBDR_naiverotation<TSpace> currentRotation(bestReflections);
233  fastCBDRtab.push_back(currentRotation);
234 
235  // display vector of reflections
236  for(size_t i = 0 ; i<bestReflections.size() ; ++i) {
237  if(i<bestReflections.size()-1)
238  file << bestReflections[i].normalVector.my_gavec << ",";
239  else
240  file << bestReflections[i].normalVector.my_gavec;
241  }
242  file << ";"<<Linf->evaluate(points,currentRotation,currentAngle,my_center);
243  file << ";"<<LContinuity->evaluate(points,currentRotation,currentAngle,my_center);
244  file << std::endl;
245 
246  }
247  file.close();
248  std::cout << "table written !"<<std::endl;
249  fastTableFound=true;
250  return fastCBDRtab;
251  }
vec since the parameters are the vectors of digitized reflections

References DGtal::CBDRSolver< TSpace, TDomain >::solve().

Referenced by DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initCBDRVec().

◆ loadFastOptimisedTable()

template<typename TSpace , typename TInputValue , typename TOutputValue >
std::vector< CBDR_naiverotation< TSpace, TInputValue > > DGtal::CBDR< TSpace, TInputValue, TOutputValue >::loadFastOptimisedTable ( const std::string &  fastTableName)
private

load fast optimised table in case the table is found

Definition at line 178 of file CBDR.h.

178  {
179  auto vecTable = DGtal::functions::loadFastCBDRTable<DGtal::SpaceND< 2, DGtal::int32_t >>(fastTableName);
180  std::vector<CBDR_naiverotation<TSpace, TInputValue>> fastCBDRtab(vecTable.size());
181  std::transform(vecTable.begin(),vecTable.end(), fastCBDRtab.begin(), [](std::tuple<std::vector<DGtal::GAVector<DGtal::SpaceND< 2, DGtal::int32_t >>>,double,double>& x) {
182  return DGtal::CBDR_naiverotation<DGtal::SpaceND< 2, DGtal::int32_t >>(std::get<0>(x));
183  });
184  return fastCBDRtab;
185  }

Referenced by DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initCBDRVec().

◆ operator()()

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CBDR< TSpace, TInputValue, TOutputValue >::operator() ( const TInputValue &  aInput) const
inline

Definition at line 130 of file CBDR.h.

131  {
132  return my_cbdr->operator()(aInput-my_center)+my_center;
133  }

References DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_cbdr, and DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_center.

◆ rotateImage()

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

Definition at line 136 of file CBDR.h.

136  {
137  return my_cbdr->rotateImage(img);
138  }

References DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_cbdr.

◆ set_angle()

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
void DGtal::CBDR< TSpace, TInputValue, TOutputValue >::set_angle ( const double  newAngle)
inline

◆ setPolicy()

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
void DGtal::CBDR< TSpace, TInputValue, TOutputValue >::setPolicy ( const std::shared_ptr< Policy< TSpace, HyperRectDomain< TSpace >, CBDR_naiverotation< TSpace >>> &  newPolicy)
inline

Definition at line 123 of file CBDR.h.

123  {
124  // need to search again for the precomputed tables
125  my_policy = newPolicy;
126  my_cbdr = initCBDRVec();
127  }

References DGtal::CBDR< TSpace, TInputValue, TOutputValue >::initCBDRVec(), DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_cbdr, and DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_policy.

◆ tostring()

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

Definition at line 140 of file CBDR.h.

140  {
141  return {"CBDR"};
142  }

Field Documentation

◆ fastCBDRTable

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
std::vector<CBDR_naiverotation<TSpace,TInputValue> > DGtal::CBDR< TSpace, TInputValue, TOutputValue >::fastCBDRTable

◆ fastTableFound

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
bool DGtal::CBDR< TSpace, TInputValue, TOutputValue >::fastTableFound
private

◆ kmax

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
size_t DGtal::CBDR< TSpace, TInputValue, TOutputValue >::kmax

◆ my_angle

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
double DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_angle

◆ my_cbdr

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
std::shared_ptr<CBDR_naiverotation<TSpace> > DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_cbdr

◆ my_center

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_center

◆ my_domain

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
HyperRectDomain<TSpace> DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_domain

◆ my_policy

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
std::shared_ptr<Policy<TSpace,HyperRectDomain< TSpace>,CBDR_naiverotation<TSpace> > > DGtal::CBDR< TSpace, TInputValue, TOutputValue >::my_policy

◆ N

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
int DGtal::CBDR< TSpace, TInputValue, TOutputValue >::N

◆ nbijectiveGen

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
NBijectiveGenerator<TSpace,TInputValue> DGtal::CBDR< TSpace, TInputValue, TOutputValue >::nbijectiveGen

◆ nbReflections

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
size_t DGtal::CBDR< TSpace, TInputValue, TOutputValue >::nbReflections

◆ useFastTable

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
bool DGtal::CBDR< TSpace, TInputValue, TOutputValue >::useFastTable

◆ usePrecomputedTable

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
bool DGtal::CBDR< TSpace, TInputValue, TOutputValue >::usePrecomputedTable

Definition at line 154 of file CBDR.h.

◆ vecBijectiveSearchTree

template<typename TSpace , typename TInputValue = typename TSpace::RealPoint, typename TOutputValue = typename TSpace::Point>
std::vector<BijectiveSearchTree> DGtal::CBDR< TSpace, TInputValue, TOutputValue >::vecBijectiveSearchTree

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