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 
public interface
PointMatcherSupport::Parametrizable Parametrizable
void filterPointness(DataPoints &pts, T xi, std::size_t k) const
void addDescriptor(DataPoints &pts, const TensorVoting< T > &tv, bool keepNormals_, bool keepLabels_, bool keepLambdas_, bool keepTensors_) const
Matrix::Index Index
An index to a row or a column.
Definition: PointMatcher.h:218
SpectralDecompositionDataPointsFilter(const Parameters &params=Parameters())
void filterSurfaceness(DataPoints &pts, T xi, std::size_t k) const
void removeOutlier(DataPoints &pts, const TensorVoting< T > &tv) const
::std::string string
Definition: gtest.h:1979
virtual DataPoints filter(const DataPoints &input)
Apply filters to input point cloud. This is the non-destructive version and returns a copy...
virtual void inPlaceFilter(DataPoints &cloud)
Apply these filters to a point cloud without copying.
Parametrizable::InvalidParameter InvalidParameter
PointMatcherSupport::Parametrizable P
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dense matrix over ScalarType.
Definition: PointMatcher.h:169
PointMatcher< T >::DataPoints::InvalidField InvalidField
void filterCurveness(DataPoints &pts, T xi, std::size_t k) const
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
static T xi_expectation(const std::size_t D, const T sigma_, const T radius_)
Functions and classes that are dependant on scalar type are defined in this templatized class...
Definition: PointMatcher.h:130
A data filter takes a point cloud as input, transforms it, and produces another point cloud as output...
Definition: PointMatcher.h:440
The documentation of a parameter.
The superclass of classes that are constructed using generic parameters. This class provides the para...
An exception thrown when one tries to fetch the value of an unexisting parameter. ...
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
An exception thrown when one tries to access features or descriptors unexisting or of wrong dimension...
Definition: PointMatcher.h:250
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector over ScalarType.
Definition: PointMatcher.h:161
Parametrizable::ParameterDoc ParameterDoc
Parametrizable::ParametersDoc ParametersDoc
static const ParametersDoc availableParameters()


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:03