Ponca  2cfe00173bb12dda99e12b2b48a0e1f683bc5cdd
Point Cloud Analysis library
Loading...
Searching...
No Matches
covariance.h
1/*
2 Copyright (C) 2021 aniket agarwalla <aniketagarwalla37@gmail.com>
3 Copyright (C) 2022 nicolas mellado <nmellado0@gmail.com>
4
5 This Source Code Form is subject to the terms of the Mozilla Public
6 License, v. 2.0. If a copy of the MPL was not distributed with this
7 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8*/
9
10#pragma once
11#include "../../defines.h"
12#include "../concepts.h"
14#include PONCA_MULTIARCH_INCLUDE_STD(cmath)
15#include PONCA_MULTIARCH_INCLUDE_CU_STD(limits)
16
17#include <Eigen/Dense>
18
19#define COVARIANCE_FIT_BASE_REQUIREMENTS ProvidesMeanPosition<T>
20#define COVARIANCE_FIT_DER_REQUIREMENTS \
21 ProvidesBasketDiffUnitBase<T>&& ProvidesMeanPositionDerivative<T>&& ProvidesPositionCovariance<T>
22
23namespace Ponca
24{
25
27
56 All the computed features are defined for the 3 eigenvalues \f$ 0 < \lambda_0
57 \leq \lambda_1 \leq \lambda_2 \f$.
58
59
60 \warning This class is valid for any dimensions, however some statistics can only be computed in 3d.
61 */
63 template <class DataPoint, class _NFilter, typename T>
64 requires COVARIANCE_FIT_BASE_REQUIREMENTS
65 class CovarianceBase : public T
66 {
67 PONCA_FITTING_DECLARE_DEFAULT_TYPES
68 public:
69 using MatrixType = typename DataPoint::MatrixType;
70 /*! \brief Solver used to analyse the covariance matrix*/
71 using Solver = Eigen::SelfAdjointEigenSolver<MatrixType>;
72
73 protected:
74 // computation data
75 MatrixType m_cov{MatrixType::Zero()};
77
78 public:
79 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(CovarianceBase, covarianceBase)
80 PONCA_FITTING_DECLARE_INIT_ADD_FINALIZE
81
83
86 */
87 PONCA_MULTIARCH [[nodiscard]] inline Scalar surfaceVariation() const;
88
90
93 */
94 PONCA_MULTIARCH [[nodiscard]] inline Scalar planarity() const;
95
97
100 */
101 PONCA_MULTIARCH [[nodiscard]] inline Scalar linearity() const;
102
104
107 */
108 PONCA_MULTIARCH [[nodiscard]] inline Scalar sphericity() const;
109
111
114 */
115 PONCA_MULTIARCH [[nodiscard]] inline Scalar anisotropy() const;
116
118
121 PONCA_MULTIARCH [[nodiscard]] inline Scalar eigenentropy() const;
122
125 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_0() const;
126
128
129 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_1() const;
130
131 /*! \brief The maximum eigenvalue \f$ \lambda_2 \f$.
132 */
133 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_2() const;
134
136 PONCA_MULTIARCH [[nodiscard]] inline const Solver& solver() const { return m_solver; }
137 };
138
144 template <class DataPoint, class _NFilter, int DiffType, typename T>
145 requires COVARIANCE_FIT_DER_REQUIREMENTS
146 class CovarianceDer : public T
147 {
148 PONCA_FITTING_DECLARE_DEFAULT_TYPES
149 PONCA_FITTING_DECLARE_MATRIX_TYPE
150 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
151 protected:
153 MatrixType m_dCov[Base::NbDerivatives];
154
155 public:
156 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(CovarianceDer, covarianceDer)
157 PONCA_FITTING_DECLARE_INIT_ADDDER_FINALIZE
158 }; // class CovarianceDer
159
160#include "covariance.hpp"
161
162} // namespace Ponca
Procedure that compute and decompose the covariance matrix of the neighbors positions.
Definition covariance.h:66
CovarianceBase< DataPoint, _NFilter, T > & covarianceBase()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition covariance.h:79
Scalar lambda_1() const
The second eigenvalue .
Definition covariance.h:107
Eigen::SelfAdjointEigenSolver< MatrixType > Solver
Solver used to analyse the covariance matrix.
Definition covariance.h:71
Scalar surfaceVariation() const
Implements pauly:2002:pssimplification surface variation.
Definition covariance.h:55
MatrixType m_cov
Covariance matrix.
Definition covariance.h:75
Scalar planarity() const
Implements the planarity guinard:2017 .
Definition covariance.h:62
Scalar sphericity() const
Implements the sphericity guinard:2017 .
Definition covariance.h:78
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Definition covariance.h:69
Scalar lambda_0() const
The minimum eigenvalue .
Definition covariance.h:100
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition covariance.h:67
Scalar anisotropy() const
Implements the anisotropy guinard:2017 .
Definition covariance.h:86
Solver m_solver
Solver used to analyse the covariance matrix.
Definition covariance.h:76
Scalar linearity() const
Implements the linearity guinard:2017 .
Definition covariance.h:70
Scalar eigenentropy() const
Implements the eigenentropy guinard:2017 .
Definition covariance.h:93
const Solver & solver() const
Reading access to the Solver used to analyze the covariance matrix.
Definition covariance.h:136
Scalar lambda_2() const
The maximum eigenvalue .
Definition covariance.h:114
Internal generic class computing the derivatives of covariance matrix computed by covarianceBase.
Definition covariance.h:147
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Definition covariance.h:149
CovarianceDer< DataPoint, _NFilter, DiffType, T > & covarianceDer()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition covariance.h:156
MatrixType m_dCov[Base::NbDerivatives]
Computation data: derivatives of the covariance matrix.
Definition covariance.h:153
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition covariance.h:148
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11