DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
TensorVotingFeatureExtraction.h
1
16
17
#pragma once
18
33
34
#if defined(TensorVotingFeatureExtraction_RECURSES)
35
#error Recursive header files inclusion detected in TensorVotingFeatureExtraction.h
36
#else
// defined(TensorVotingFeatureExtraction_RECURSES)
38
#define TensorVotingFeatureExtraction_RECURSES
39
40
#if !defined TensorVotingFeatureExtraction_h
42
#define TensorVotingFeatureExtraction_h
43
45
// Inclusions
46
#include <iostream>
47
#include <DGtal/base/Common.h>
48
#include <DGtal/topology/SCellsFunctors.h>
49
#include <vector>
50
#include "DGtal/math/linalg/SimpleMatrix.h"
51
#include "DGtal/math/linalg/EigenDecomposition.h"
53
54
namespace
DGtal
55
{
56
namespace
functors
57
{
59
// template class TensorVotingFeatureExtraction
80
template
<
typename
TSurfel,
typename
TEmbedder>
81
class
TensorVotingFeatureExtraction
82
{
83
public
:
84
85
typedef
TSurfel
Surfel
;
86
typedef
TEmbedder
SCellEmbedder
;
87
typedef
typename
SCellEmbedder::RealPoint
RealPoint
;
88
typedef
double
Quantity
;
89
96
TensorVotingFeatureExtraction
(
ConstAlias<SCellEmbedder>
anEmbedder,
97
const
double
h):
98
myEmbedder
(&anEmbedder),
myH
(h)
99
{
100
myId
.
identity
();
101
myArea
= 0.0;
102
myFirstSurfel
=
true
;
103
myAccum
.
constant
(0.0);
104
}
105
113
void
pushSurfel
(
const
Surfel
& aSurf,
114
const
double
aDistance)
115
{
116
if
(
myFirstSurfel
)
117
{
118
myReceiver
=
myEmbedder
->operator()(aSurf);
119
myFirstSurfel
=
false
;
120
}
121
else
122
{
123
myArea
+= aDistance;
124
const
RealPoint
p =
myEmbedder
->operator()(aSurf);
125
const
RealPoint
v = p -
myReceiver
;
126
127
double
maxcol = 0.0;
128
double
matnorm = 0.0;
129
130
// I - vv^t/||vv^t||
131
for
(
DGtal::Dimension
i= 0; i <3; i++)
132
{
133
maxcol = 0.0;
134
for
(
DGtal::Dimension
j=0; j < 3; j++)
135
{
136
myVote
.
setComponent
(i,j, v(i)*v(j));
137
if
(std::abs(v(i)*v(j)) > maxcol)
138
maxcol = std::abs(v(i)*v(j));
139
}
140
matnorm += maxcol;
141
}
142
143
myAccum
+= (
myId
-
myVote
/matnorm)*aDistance;
144
}
145
}
146
154
Quantity
eval
( )
155
{
156
SimpleMatrix<double, 3, 3>
eigenvectors;
157
RealPoint
eigenvalues;
158
159
myAccum
/=
myArea
;
160
EigenDecomposition<3, double>::getEigenDecomposition
(
myAccum
, eigenvectors, eigenvalues);
161
162
#ifdef DEBUG
163
for
(
Dimension
i_dim = 1; i_dim < 3; ++i_dim )
164
ASSERT ( std::abs(eigenvalues[i_dim - 1]) <= std::abs(eigenvalues[i_dim]) );
165
#endif
166
167
return
((eigenvalues[0] + eigenvalues[1])/(eigenvalues[2]));
168
}
169
174
void
reset
()
175
{
176
myArea
= 0.0;
177
myFirstSurfel
=
true
;
178
myAccum
.
constant
(0.0);
179
}
180
181
182
private
:
183
185
bool
myFirstSurfel
;
186
188
const
SCellEmbedder
*
myEmbedder
;
189
190
//Grid step
191
double
myH
;
192
194
RealPoint
myReceiver
;
195
197
SimpleMatrix<double, 3, 3>
myAccum
,
myId
,
myVote
;
198
200
double
myArea
;
201
202
};
// end of class TensorVotingFeatureExtraction
203
}
//namespace functors
204
}
// namespace DGtal
205
206
207
// //
209
210
#endif
// !defined TensorVotingFeatureExtraction_h
211
212
#undef TensorVotingFeatureExtraction_RECURSES
213
#endif
// else defined(TensorVotingFeatureExtraction_RECURSES)
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition
ConstAlias.h:187
DGtal::EigenDecomposition::getEigenDecomposition
static void getEigenDecomposition(const Matrix &matrix, Matrix &eigenVectors, Vector &eigenValues)
Compute both eigen vectors and eigen values from an input matrix.
DGtal::SimpleMatrix
Aim: implements basic MxN Matrix services (M,N>=1).
Definition
SimpleMatrix.h:76
DGtal::SimpleMatrix::identity
void identity()
DGtal::SimpleMatrix::setComponent
void setComponent(const DGtal::Dimension i, const DGtal::Dimension j, const Component &aValue)
DGtal::SimpleMatrix::constant
void constant(const Component &aScalar)
DGtal::functors::TensorVotingFeatureExtraction::Quantity
double Quantity
Definition
TensorVotingFeatureExtraction.h:88
DGtal::functors::TensorVotingFeatureExtraction::myArea
double myArea
Convolution kernel area.
Definition
TensorVotingFeatureExtraction.h:200
DGtal::functors::TensorVotingFeatureExtraction::myEmbedder
const SCellEmbedder * myEmbedder
Alias of the geometrical embedder.
Definition
TensorVotingFeatureExtraction.h:188
DGtal::functors::TensorVotingFeatureExtraction::Surfel
TSurfel Surfel
Definition
TensorVotingFeatureExtraction.h:85
DGtal::functors::TensorVotingFeatureExtraction::pushSurfel
void pushSurfel(const Surfel &aSurf, const double aDistance)
Definition
TensorVotingFeatureExtraction.h:113
DGtal::functors::TensorVotingFeatureExtraction::TensorVotingFeatureExtraction
TensorVotingFeatureExtraction(ConstAlias< SCellEmbedder > anEmbedder, const double h)
Definition
TensorVotingFeatureExtraction.h:96
DGtal::functors::TensorVotingFeatureExtraction::myAccum
SimpleMatrix< double, 3, 3 > myAccum
Covariance accumulator.
Definition
TensorVotingFeatureExtraction.h:197
DGtal::functors::TensorVotingFeatureExtraction::RealPoint
SCellEmbedder::RealPoint RealPoint
Definition
TensorVotingFeatureExtraction.h:87
DGtal::functors::TensorVotingFeatureExtraction::myH
double myH
Definition
TensorVotingFeatureExtraction.h:191
DGtal::functors::TensorVotingFeatureExtraction::myFirstSurfel
bool myFirstSurfel
First surfel flag.
Definition
TensorVotingFeatureExtraction.h:185
DGtal::functors::TensorVotingFeatureExtraction::myVote
SimpleMatrix< double, 3, 3 > myVote
Definition
TensorVotingFeatureExtraction.h:197
DGtal::functors::TensorVotingFeatureExtraction::myReceiver
RealPoint myReceiver
Receiver (embedding of the starting surfel).
Definition
TensorVotingFeatureExtraction.h:194
DGtal::functors::TensorVotingFeatureExtraction::reset
void reset()
Definition
TensorVotingFeatureExtraction.h:174
DGtal::functors::TensorVotingFeatureExtraction::myId
SimpleMatrix< double, 3, 3 > myId
Definition
TensorVotingFeatureExtraction.h:197
DGtal::functors::TensorVotingFeatureExtraction::eval
Quantity eval()
Definition
TensorVotingFeatureExtraction.h:154
DGtal::functors::TensorVotingFeatureExtraction::SCellEmbedder
TEmbedder SCellEmbedder
Definition
TensorVotingFeatureExtraction.h:86
DGtal::functors
functors namespace gathers all DGtal functors.
Definition
BasicBoolFunctors.h:49
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::Dimension
DGtal::uint32_t Dimension
Definition
Common.h:119
src
DGtal
geometry
surfaces
estimation
estimationFunctors
TensorVotingFeatureExtraction.h
Generated on
for DGtal by
1.18.0