15 #include <gudhi/Persistence_heat_maps.h> 22 namespace Persistence_representations {
38 PSSK(
const std::vector<std::pair<double, double> >& interval,
39 std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1),
size_t number_of_pixels = 1000,
40 double min_ = -1,
double max_ = -1)
42 this->construct(interval, filter, number_of_pixels, min_, max_);
45 PSSK(
const char* filename, std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1),
46 size_t number_of_pixels = 1000,
double min_ = -1,
double max_ = -1,
47 unsigned dimension = std::numeric_limits<unsigned>::max())
49 std::vector<std::pair<double, double> > intervals_;
50 if (dimension == std::numeric_limits<unsigned>::max()) {
51 intervals_ = read_persistence_intervals_in_one_dimension_from_file(filename);
53 intervals_ = read_persistence_intervals_in_one_dimension_from_file(filename, dimension);
55 this->construct(intervals_, filter, number_of_pixels, min_, max_);
59 void construct(
const std::vector<std::pair<double, double> >& intervals_,
60 std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1),
61 size_t number_of_pixels = 1000,
double min_ = -1,
double max_ = -1);
65 void PSSK::construct(
const std::vector<std::pair<double, double> >& intervals_,
66 std::vector<std::vector<double> > filter,
size_t number_of_pixels,
double min_,
double max_) {
69 std::cerr <<
"Entering construct procedure \n";
75 min_ = std::numeric_limits<int>::max();
76 max_ = -std::numeric_limits<int>::max();
78 for (
size_t i = 0; i != intervals_.size(); ++i) {
79 if (intervals_[i].first < min_) min_ = intervals_[i].first;
80 if (intervals_[i].second > max_) max_ = intervals_[i].second;
86 min_ -= fabs(max_ - min_) / 100;
87 max_ += fabs(max_ - min_) / 100;
91 std::cerr <<
"min_ : " << min_ << std::endl;
92 std::cerr <<
"max_ : " << max_ << std::endl;
93 std::cerr <<
"number_of_pixels : " << number_of_pixels << std::endl;
101 std::vector<std::vector<double> > heat_map_;
102 for (
size_t i = 0; i != number_of_pixels; ++i) {
103 std::vector<double> v(number_of_pixels, 0);
104 heat_map_.push_back(v);
106 this->heat_map = heat_map_;
108 if (dbg) std::cerr <<
"Done creating of the heat map, now we will fill in the structure \n";
110 for (
size_t pt_nr = 0; pt_nr != intervals_.size(); ++pt_nr) {
113 static_cast<int>((intervals_[pt_nr].first - this->min_) / (this->max_ - this->min_) * number_of_pixels);
115 static_cast<int>((intervals_[pt_nr].second - this->min_) / (this->max_ - this->min_) * number_of_pixels);
118 std::cerr <<
"point : " << intervals_[pt_nr].first <<
" , " << intervals_[pt_nr].second << std::endl;
119 std::cerr <<
"x_grid : " << x_grid << std::endl;
120 std::cerr <<
"y_grid : " << y_grid << std::endl;
125 x_grid -= filter.size() / 2;
126 y_grid -= filter.size() / 2;
130 std::cerr <<
"After shift : \n";
131 std::cerr <<
"x_grid : " << x_grid << std::endl;
132 std::cerr <<
"y_grid : " << y_grid << std::endl;
133 std::cerr <<
"filter.size() : " << filter.size() << std::endl;
137 for (
size_t i = 0; i != filter.size(); ++i) {
138 for (
size_t j = 0; j != filter.size(); ++j) {
140 if (((x_grid + i) >= 0) && (x_grid + i < this->heat_map.size()) && ((y_grid + j) >= 0) &&
141 (y_grid + j < this->heat_map.size())) {
143 std::cerr << y_grid + j <<
" " << x_grid + i << std::endl;
145 this->heat_map[y_grid + j][x_grid + i] += filter[i][j];
146 this->heat_map[x_grid + i][y_grid + j] += -filter[i][j];
A class implementing persistence heat maps.
Definition: Persistence_heat_maps.h:178
Definition: SimplicialComplexForAlpha.h:14
Persistence_heat_maps()
Definition: Persistence_heat_maps.h:184