Helios++
Helios software for LiDAR simulations
SingularContextComputer.hpp
1 #ifndef _SURFACEINSPECTOR_MATHS_SINGULARCONTEXTCOMPUTER_HPP_
2 #define _SURFACEINSPECTOR_MATHS_SINGULARCONTEXTCOMPUTER_HPP_
3 
4 #include <vector>
5 #include <armadillo>
6 
7 #include <util/Object.hpp>
8 #include <maths/SingularContextDescriptors.hpp>
9 
10 using std::vector;
11 using arma::Mat;
12 
15 
16 namespace SurfaceInspector { namespace maths{
17 
110 template <typename T>
112 public:
113  // *** ATTRIBUTES *** //
114  // ******************** //
129  size_t aWorst;
134  size_t aBest;
139  size_t bWorst;
144  size_t bBest;
145 
150  bool absoluteComponents = false;
160  void (SingularContextComputer<T>::*normalize) (Mat<T> &M) const;
170  void (SingularContextComputer<T>::*center) (Mat<T> &M) const;
171 
178  vector<T> aNorm;
185  vector<T> bNorm;
191  vector<T> deltaNorm;
192 
193  // *** CONSTRUCTION / DESTRUCTION *** //
194  // ************************************ //
200  {init(true, true, 1, 1, 1, 1);}
206  {init(normalize, center, 1, 1, 1, 1);}
212  size_t aWorst,
213  size_t aBest,
214  size_t bWorst,
215  size_t bBest
216  )
217  {init(true, true, aWorst, aBest, bWorst, bBest);}
223  bool normalize,
224  bool center,
225  size_t aWorst,
226  size_t aBest,
227  size_t bWorst,
228  size_t bBest
229  )
231  virtual ~SingularContextComputer() {};
232 
233  // *** INITIALIZE *** //
234  // ******************** //
244  void init(
245  bool normalize,
246  bool center,
247  size_t aWorst,
248  size_t aBest,
249  size_t bWorst,
250  size_t bBest
251  );
252 
253  // *** MAIN FUNCTIONS *** //
254  // ************************ //
265 
266  // *** AUXILIAR FUNCTIONS *** //
267  // **************************** //
274  vector<size_t> alpha(arma::vec const &v, size_t const a) const;
281  vector<size_t> beta(arma::vec const &v, size_t const b) const;
289  vector<T> extractComponents(
290  arma::vec const &v,
291  vector<size_t> indices
292  ) const;
293 
294  // *** NORMALIZATION *** //
295  // *********************** //
304  void configureNorm(vector<T> const &a, vector<T> const &b);
311  void configureNorm(vector<vector<T>> const &X);
316  void normalizeDefault(Mat<T> &M) const;
327  void normalizeRGB(Mat<T> &M) const;
334  void normalizeHSO(Mat<T> &M) const;
341  void normalizeHLI(Mat<T> &M) const;
348  void normalizeLP(Mat<T> &M) const;
355  void normalizeGdCd(Mat<T> &M) const;
362  void normalizeGdCdI(Mat<T> &M) const;
369  void normalizeHV(Mat<T> &M) const;
376  void normalizeSO(Mat<T> &M) const;
383  void normalizeLC(Mat<T> &M) const;
390  void normalizeVC(Mat<T> &M) const;
397  void normalizePC(Mat<T> &M) const;
404  void normalizeVR(Mat<T> &M) const;
410  void normalizeCone(Mat<T> &M) const;
417  void normalizeHyperbolicParaboloid(Mat<T> &M) const;
418 
419  // *** CENTERING *** //
420  // ******************* //
425  void centerDefault(Mat<T> &M) const;
426 };
427 }}
428 
429 #include <maths/SingularContextComputer.tpp>
430 
431 #endif
Handle singular context descriptors computation.
Definition: SingularContextComputer.hpp:111
vector< size_t > beta(arma::vec const &v, size_t const b) const
Extract indices for maximum values of .
bool normalizeFlag
Flag which specifies if the singular context computer must normalize when computing descriptors (true...
Definition: SingularContextComputer.hpp:119
void init(bool normalize, bool center, size_t aWorst, size_t aBest, size_t bWorst, size_t bBest)
Initialize the singular context computer.
void normalizeGdCd(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are GdCd (Ground-distance and Ceiling-distanc...
vector< T > deltaNorm
Definition: SingularContextComputer.hpp:191
void normalizeHSO(Mat< T > &M) const
Normalize given matrix assuming each first 3 components are HSO (Horizontality, Sum and Omnivariance)...
size_t bBest
How many maximum values consider when computing the function for the best fitting vector.
Definition: SingularContextComputer.hpp:144
void normalizeLP(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are LP (Linearity and Planarity)
void normalizeVR(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are VR (Verticality and Roughness)
void normalizeVC(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are VC (Verticality and Curvature)
SingularContextComputer(bool normalize, bool center)
Non default constructor for singular context computer.
Definition: SingularContextComputer.hpp:205
void normalizePC(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are PC (Planarity and Curvature)
SingularContextDescriptors< T > describe(Mat< T > &M) const
Obtain singular context descriptors from given matrix.
vector< T > extractComponents(arma::vec const &v, vector< size_t > indices) const
Extract components of given vector corresponding to given indices.
void centerDefault(Mat< T > &M) const
Center given matrix by default criteria.
SingularContextComputer(bool normalize, bool center, size_t aWorst, size_t aBest, size_t bWorst, size_t bBest)
Non default constructor for singular context computer.
Definition: SingularContextComputer.hpp:222
void normalizeSO(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are SO (Sum and Omnivariance)
void normalizeLC(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are LC (Linearity and Curvature)
void normalizeHLI(Mat< T > &M) const
Normalize given matrix assuming each first 3 components are HLI (Horizontality, Linearity and Intensi...
void(SingularContextComputer< T >::* normalize)(Mat< T > &M) const
Function which normalizes the matrix if necessary. A default implementation is provided as the normal...
Definition: SingularContextComputer.hpp:160
vector< T > aNorm
The vector must contain the start of normalization interval if the normalization strategy requires i...
Definition: SingularContextComputer.hpp:178
void normalizeGdCdI(Mat< T > &M) const
Normalize given matrix assuming each first 3 components are GdCdI (Ground-distance,...
void(SingularContextComputer< T >::* center)(Mat< T > &M) const
Function which centers the matrix if necessary. A default implementation is provided as the centerDef...
Definition: SingularContextComputer.hpp:170
size_t aWorst
How many minimum values consider when computing the function for the worst fitting vector.
Definition: SingularContextComputer.hpp:129
void normalizeCone(Mat< T > &M) const
Normalize given matrix assuming (X,Y,Z) components for a cone.
SingularContextComputer()
Default constructor for singular context computer.
Definition: SingularContextComputer.hpp:199
vector< T > bNorm
The vector must contain the end of normalization interval if the normalization strategy requires it.
Definition: SingularContextComputer.hpp:185
size_t aBest
How many minimum values consider when computing the function for the best fitting vector.
Definition: SingularContextComputer.hpp:134
void configureNorm(vector< T > const &a, vector< T > const &b)
Configure normalization vectors from given ones.
size_t bWorst
How many minimum values consider when computing the function for the worst fitting vector.
Definition: SingularContextComputer.hpp:139
void configureNorm(vector< vector< T >> const &X)
Configure normalization vectors from given matrix.
void normalizeHyperbolicParaboloid(Mat< T > &M) const
Normalize given matrix assuming (X,Y,Z) components for a hyperbolic paraboloid.
void normalizeRGB(Mat< T > &M) const
Normalize given matrix assuming each first 3 components are RGB so they must be inside interval.
bool absoluteComponents
Specify if use absolute values of the singular vector components (true) or consider their signed vers...
Definition: SingularContextComputer.hpp:150
SingularContextComputer(size_t aWorst, size_t aBest, size_t bWorst, size_t bBest)
Non default constructor for singular context computer.
Definition: SingularContextComputer.hpp:211
vector< size_t > alpha(arma::vec const &v, size_t const a) const
Extract indices for minimum values of .
void normalizeHV(Mat< T > &M) const
Normalize given matrix assuming each first 2 components are HV (Horizontality and Verticality)
bool centerFlag
Flag which specifies if the singular context computer must center when computing descriptors (true) o...
Definition: SingularContextComputer.hpp:124
void normalizeDefault(Mat< T > &M) const
Normalize given matrix by default criteria.
Class representing singular context descriptors.
Definition: SingularContextDescriptors.hpp:20
Class representing an object. All surface inspector classes must extend Object.
Definition: Object.hpp:12