-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathWeightMap.hpp
55 lines (46 loc) · 1.43 KB
/
WeightMap.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* WeightMap.h
*
* Created on: 12/feb/2015
* Author: nicola
*/
#ifndef DA3D_WEIGHTMAP_HPP_
#define DA3D_WEIGHTMAP_HPP_
#include <cassert>
#include <vector>
namespace da3d {
class Image;
class WeightMap {
public:
WeightMap() = default;
WeightMap(int rows, int columns);
~WeightMap() = default;
void Init(int rows, int columns);
float Minimum() const;
std::pair<int, int> FindMinimum() const;
void IncreaseWeights(const Image &weights, int row0, int col0);
int width() const { return width_; }
int height() const { return height_; }
int num_levels() const { return num_levels_; }
float val(int col, int row, int level = 0) const;
float &val(int col, int row, int level = 0);
const float* data() const { return data_[0].data(); }
private:
int num_levels_{0}, width_{0}, height_{0};
std::vector<int> rows_, columns_;
std::vector<std::vector<float>> data_;
};
inline float WeightMap::val(int col, int row, int level) const {
assert (0 <= level && level < num_levels_);
assert (0 <= col && col < columns_[level]);
assert (0 <= row && row < rows_[level]);
return data_[level][columns_[level] * row + col];
}
inline float &WeightMap::val(int col, int row, int level) {
assert (0 <= level && level < num_levels_);
assert (0 <= col && col < columns_[level]);
assert (0 <= row && row < rows_[level]);
return data_[level][columns_[level] * row + col];
}
} // namespace da3d
#endif // DA3D_WEIGHTMAP_HPP_