38 #ifndef PCL_ML_PERMUTOHEDRAL_H_ 39 #define PCL_ML_PERMUTOHEDRAL_H_ 42 #pragma GCC system_header 47 #include <pcl/common/eigen.h> 48 #include <boost/intrusive/hashtable.hpp> 76 Neighbors (
int n1 = 0,
int n2 = 0) : n1 (n1), n2 (n2) {}
89 init (
const std::vector<float> &feature,
const int feature_dimension,
const int N);
92 compute (std::vector<float> &out,
const std::vector<float> &in,
94 int in_offset=0,
int out_offset=0,
95 int in_size = -1,
int out_size = -1)
const;
97 initOLD (
const std::vector<float> &feature,
const int feature_dimension,
const int N);
100 computeOLD (std::vector<float> &out,
const std::vector<float> &in,
102 int in_offset=0,
int out_offset=0,
103 int in_size = -1,
int out_size = -1)
const;
113 for (
int i = 0; i <
d_; i++)
145 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
153 table_ =
new int[ capacity_ ];
154 keys_ =
new short[ (capacity_/2+10)*key_size_ ];
155 memset( table_, -1, capacity_*
sizeof(
int) );
162 std::cout <<
"GROW" << std::endl;
165 short * old_keys = keys_;
166 int * old_table = table_;
167 int old_capacity =
static_cast<int> (capacity_);
170 keys_ =
new short[ (old_capacity+10)*key_size_ ];
171 table_ =
new int[ capacity_ ];
172 memset( table_, -1, capacity_*
sizeof(
int) );
173 memcpy( keys_, old_keys, filled_*key_size_*
sizeof(
short) );
176 for(
int i=0; i<old_capacity; i++ )
177 if (old_table[i] >= 0){
178 int e = old_table[i];
179 size_t h = hash( old_keys+(getKey(e)-keys_) ) % capacity_;
180 for (; table_[h] >= 0; h = h<capacity_-1 ? h+1 : 0) { };
187 size_t hash(
const short * k ) {
189 for(
size_t i=0; i<key_size_; i++ ){
196 explicit HashTableOLD(
int key_size,
int n_elements ) : key_size_ ( key_size ), filled_(0), capacity_(2*n_elements) {
197 table_ =
new int[ capacity_ ];
198 keys_ =
new short[ (capacity_/2+10)*key_size_ ];
199 memset( table_, -1, capacity_*
sizeof(
int) );
206 return static_cast<int> (filled_);
210 memset( table_, -1, capacity_*
sizeof(
int) );
212 int find(
const short * k,
bool create =
false ){
213 if (2*filled_ >= capacity_) grow();
215 size_t h = hash( k ) % capacity_;
222 for(
size_t i=0; i<key_size_; i++ )
223 keys_[ filled_*key_size_+i ] = k[i];
224 return table_[h] =
static_cast<int> (filled_++);
231 for(
size_t i=0; i<key_size_ && good; i++ )
232 if (keys_[ e*key_size_+i ] != k[i])
238 if (h==capacity_) h = 0;
242 return keys_+i*key_size_;
Implementation of a high-dimensional gaussian filtering using the permutohedral lattice.
size_t hash(const short *k)
std::vector< Neighbors > blur_neighbors_
void initOLD(const std::vector< float > &feature, const int feature_dimension, const int N)
This file defines compatibility wrappers for low level I/O functions.
std::vector< float > offset_
HashTableOLD(int key_size, int n_elements)
const short * getKey(int i) const
size_t generateHashKey(const std::vector< short > &k)
Permutohedral()
Constructor for Permutohedral class.
int find(const short *k, bool create=false)
std::vector< float > baryOLD_
int N_
Number of variables.
void init(const std::vector< float > &feature, const int feature_dimension, const int N)
initialization
~Permutohedral()
Deconstructor for Permutohedral class.
void computeOLD(std::vector< float > &out, const std::vector< float > &in, int value_size, int in_offset=0, int out_offset=0, int in_size=-1, int out_size=-1) const
std::vector< float > offsetTMP_
std::vector< float > barycentric_
Neighbors(int n1=0, int n2=0)
int d_
dimension of feature
void compute(std::vector< float > &out, const std::vector< float > &in, int value_size, int in_offset=0, int out_offset=0, int in_size=-1, int out_size=-1) const
Neighbors * blur_neighborsOLD_
int M_
size of sparse discretized space