SpectralDecomposition.h
Go to the documentation of this file.
1 // kate: replace-tabs off; indent-width 4; indent-mode normal
2 // vim: ts=4:sw=4:noexpandtab
3 /*
4 
5 Copyright (c) 2010--2018,
6 Fran├žois Pomerleau and Stephane Magnenat, ASL, ETHZ, Switzerland
7 You can contact the authors at <f dot pomerleau at gmail dot com> and
8 <stephane at magnenat dot net>
9 
10 All rights reserved.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright
15  notice, this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19  * Neither the name of the <organization> nor the
20  names of its contributors may be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL ETH-ASL BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 #pragma once
36 
37 #include "PointMatcher.h"
38 #include "utils/sparsetv.h"
39 
48 template<typename T>
50 {
51  // Type definitions
53  typedef typename PM::DataPoints DataPoints;
54  typedef typename PM::DataPoints DP;
56 
63 
64  typedef typename DataPoints::Index Index;
65 
67 
68  typedef typename PM::Matrix Matrix;
69  typedef typename PM::Vector Vector;
70 
71  inline static const std::string description()
72  {
73  return "Point cloud sampling and enhancement: compute geometric features saliencies throught Tensor Voting framework and use them to sample the point cloud. \\cite{Labussiere2020}";
74  }
75 
76  inline static const ParametersDoc availableParameters()
77  {
78  return {
79  {"k", "Number of neighbors to consider", "50", "6", "4294967295", &P::Comp<std::size_t>},
80  {"sigma", "Scale of the vote in TensorVoting.", "0.2", "0.", "+inf", &P::Comp<T>},
81  {"radius", "Radius to control the scale of the uniform distribution.", "0.4", "0.", "+inf", &P::Comp<T>},
82  {"itMax", "Number max of iterations to do", "10", "1", "4294967295", &P::Comp<std::size_t>},
83  {"keepNormals", "Flag to keep normals computed by TV.", "1", "0", "1", P::Comp<bool>},
84  {"keepLabels", "Flag to keep labels computed by TV.", "1", "0", "1", P::Comp<bool>},
85  {"keepLambdas", "Flag to keep lambdas computed by TV.", "1", "0", "1", P::Comp<bool>},
86  {"keepTensors", "Flag to keep elements Tensors computed by TV.", "1", "0", "1", P::Comp<bool>}
87  };
88  }
89 
90 public:
91  const std::size_t k;
92  const T sigma;
93  const T radius;
94  const std::size_t itMax;
95  const bool keepNormals;
96  const bool keepLabels;
97  const bool keepLambdas;
98  const bool keepTensors;
99 
100  //Ctor, uses parameter interface
102  //SpectralDecompositionDataPointsFilter();
103 
104  //Dtor
106 
107  virtual DataPoints filter(const DataPoints& input);
108  virtual void inPlaceFilter(DataPoints& cloud);
109 
110 private:
111  static T xi_expectation(const std::size_t D, const T sigma_, const T radius_)
112  {
113  return (D == 1) ? //on a curve
114  (std::sqrt(M_PI * sigma_) * std::erf(radius_ / std::sqrt(sigma_))) / (2. * radius_)
115  : (D == 2) ? //on a surface
116  (sigma_ - sigma_ * std::exp(- radius_ * radius_ / sigma_)) / (radius_ * radius_)
117  : (D == 3) ?//on a sphere
118  3. * sigma_ * (std::sqrt(M_PI * sigma_) * std::erf(radius_ / std::sqrt(sigma_)) - 2. * radius_ * std::exp(- radius_ * radius_ / sigma_)) / (4. * radius_ * radius_ * radius_)
119  : T(1.); //otherwise
120  }
121 
122  void addDescriptor(DataPoints& pts, const TensorVoting<T> &tv, bool keepNormals_, bool keepLabels_, bool keepLambdas_, bool keepTensors_) const;
123 
124  void removeOutlier(DataPoints& pts, const TensorVoting<T> &tv) const;
125 
126  void filterSurfaceness(DataPoints& pts, T xi, std::size_t k) const;
127  void filterCurveness(DataPoints& pts, T xi, std::size_t k) const;
128  void filterPointness(DataPoints& pts, T xi, std::size_t k) const;
129 };
130 
131 
SpectralDecompositionDataPointsFilter::Index
DataPoints::Index Index
Definition: SpectralDecomposition.h:64
SpectralDecompositionDataPointsFilter::radius
const T radius
Definition: SpectralDecomposition.h:93
SpectralDecompositionDataPointsFilter::inPlaceFilter
virtual void inPlaceFilter(DataPoints &cloud)
Apply these filters to a point cloud without copying.
Definition: SpectralDecomposition.cpp:65
SpectralDecompositionDataPointsFilter::SpectralDecompositionDataPointsFilter
SpectralDecompositionDataPointsFilter(const Parameters &params=Parameters())
Definition: SpectralDecomposition.cpp:41
SpectralDecompositionDataPointsFilter::~SpectralDecompositionDataPointsFilter
virtual ~SpectralDecompositionDataPointsFilter()
Definition: SpectralDecomposition.h:105
SpectralDecompositionDataPointsFilter::filterCurveness
void filterCurveness(DataPoints &pts, T xi, std::size_t k) const
Definition: SpectralDecomposition.cpp:282
SpectralDecompositionDataPointsFilter::DataPointsFilter
PM::DataPointsFilter DataPointsFilter
Definition: SpectralDecomposition.h:55
SpectralDecompositionDataPointsFilter::keepNormals
const bool keepNormals
Definition: SpectralDecomposition.h:95
SpectralDecompositionDataPointsFilter::Vector
PM::Vector Vector
Definition: SpectralDecomposition.h:69
build_map.T
T
Definition: build_map.py:34
SpectralDecompositionDataPointsFilter::sigma
const T sigma
Definition: SpectralDecomposition.h:92
SpectralDecompositionDataPointsFilter::DataPoints
PM::DataPoints DataPoints
Definition: SpectralDecomposition.h:53
PointMatcher
Functions and classes that are dependant on scalar type are defined in this templatized class.
Definition: PointMatcher.h:130
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
TensorVoting
Definition: sparsetv.h:52
SpectralDecompositionDataPointsFilter::InvalidField
PointMatcher< T >::DataPoints::InvalidField InvalidField
Definition: SpectralDecomposition.h:66
SpectralDecompositionDataPointsFilter::InvalidParameter
Parametrizable::InvalidParameter InvalidParameter
Definition: SpectralDecomposition.h:62
testing::internal::string
::std::string string
Definition: gtest.h:1979
SpectralDecompositionDataPointsFilter::PM
PointMatcher< T > PM
Definition: SpectralDecomposition.h:52
SpectralDecompositionDataPointsFilter::ParameterDoc
Parametrizable::ParameterDoc ParameterDoc
Definition: SpectralDecomposition.h:60
SpectralDecompositionDataPointsFilter::addDescriptor
void addDescriptor(DataPoints &pts, const TensorVoting< T > &tv, bool keepNormals_, bool keepLabels_, bool keepLambdas_, bool keepTensors_) const
Definition: SpectralDecomposition.cpp:134
PointMatcher::DataPoints::InvalidField
An exception thrown when one tries to access features or descriptors unexisting or of wrong dimension...
Definition: PointMatcher.h:250
PointMatcherSupport::Parametrizable::ParametersDoc
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
Definition: Parametrizable.h:187
align_sequence.params
params
Definition: align_sequence.py:13
SpectralDecompositionDataPointsFilter::itMax
const std::size_t itMax
Definition: SpectralDecomposition.h:94
PointMatcher::Matrix
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dense matrix over ScalarType.
Definition: PointMatcher.h:169
PointMatcher::DataPointsFilter
A data filter takes a point cloud as input, transforms it, and produces another point cloud as output...
Definition: PointMatcher.h:440
SpectralDecompositionDataPointsFilter::keepTensors
const bool keepTensors
Definition: SpectralDecomposition.h:98
sparsetv.h
PointMatcherSupport::Parametrizable::InvalidParameter
An exception thrown when one tries to fetch the value of an unexisting parameter.
Definition: Parametrizable.h:144
SpectralDecompositionDataPointsFilter
Definition: SpectralDecomposition.h:49
SpectralDecompositionDataPointsFilter::description
static const std::string description()
Definition: SpectralDecomposition.h:71
PointMatcher::Vector
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector over ScalarType.
Definition: PointMatcher.h:161
PointMatcher::DataPoints::Index
Matrix::Index Index
An index to a row or a column.
Definition: PointMatcher.h:218
SpectralDecompositionDataPointsFilter::filterPointness
void filterPointness(DataPoints &pts, T xi, std::size_t k) const
Definition: SpectralDecomposition.cpp:319
SpectralDecompositionDataPointsFilter::k
const std::size_t k
Definition: SpectralDecomposition.h:91
SpectralDecompositionDataPointsFilter::Parameters
Parametrizable::Parameters Parameters
Definition: SpectralDecomposition.h:59
SpectralDecompositionDataPointsFilter::keepLambdas
const bool keepLambdas
Definition: SpectralDecomposition.h:97
PointMatcherSupport::Parametrizable
The superclass of classes that are constructed using generic parameters. This class provides the para...
Definition: Parametrizable.h:141
SpectralDecompositionDataPointsFilter::P
PointMatcherSupport::Parametrizable P
Definition: SpectralDecomposition.h:58
SpectralDecompositionDataPointsFilter::ParametersDoc
Parametrizable::ParametersDoc ParametersDoc
Definition: SpectralDecomposition.h:61
PointMatcherSupport::Parametrizable::ParameterDoc
The documentation of a parameter.
Definition: Parametrizable.h:160
SpectralDecompositionDataPointsFilter::Parametrizable
PointMatcherSupport::Parametrizable Parametrizable
Definition: SpectralDecomposition.h:57
SpectralDecompositionDataPointsFilter::removeOutlier
void removeOutlier(DataPoints &pts, const TensorVoting< T > &tv) const
Definition: SpectralDecomposition.cpp:203
SpectralDecompositionDataPointsFilter::DP
PM::DataPoints DP
Definition: SpectralDecomposition.h:54
SpectralDecompositionDataPointsFilter::xi_expectation
static T xi_expectation(const std::size_t D, const T sigma_, const T radius_)
Definition: SpectralDecomposition.h:111
PointMatcher.h
public interface
SpectralDecompositionDataPointsFilter::keepLabels
const bool keepLabels
Definition: SpectralDecomposition.h:96
SpectralDecompositionDataPointsFilter::filter
virtual DataPoints filter(const DataPoints &input)
Apply filters to input point cloud. This is the non-destructive version and returns a copy.
Definition: SpectralDecomposition.cpp:57
SpectralDecompositionDataPointsFilter::Matrix
PM::Matrix Matrix
Definition: SpectralDecomposition.h:68
SpectralDecompositionDataPointsFilter::filterSurfaceness
void filterSurfaceness(DataPoints &pts, T xi, std::size_t k) const
Definition: SpectralDecomposition.cpp:245
PointMatcherSupport::Parametrizable::Parameters
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
Definition: Parametrizable.h:199
SpectralDecompositionDataPointsFilter::availableParameters
static const ParametersDoc availableParameters()
Definition: SpectralDecomposition.h:76


libpointmatcher
Author(s):
autogenerated on Mon Jan 1 2024 03:24:43