27 #include <gudhi/Persistence_heat_maps.h> 34 namespace Persistence_representations {
50 PSSK(
const std::vector<std::pair<double, double> >& interval,
51 std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1),
size_t number_of_pixels = 1000,
52 double min_ = -1,
double max_ = -1)
54 this->construct(interval, filter, number_of_pixels, min_, max_);
57 PSSK(
const char* filename, std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1),
58 size_t number_of_pixels = 1000,
double min_ = -1,
double max_ = -1,
59 unsigned dimension = std::numeric_limits<unsigned>::max())
61 std::vector<std::pair<double, double> > intervals_;
62 if (dimension == std::numeric_limits<unsigned>::max()) {
63 intervals_ = read_persistence_intervals_in_one_dimension_from_file(filename);
65 intervals_ = read_persistence_intervals_in_one_dimension_from_file(filename, dimension);
67 this->construct(intervals_, filter, number_of_pixels, min_, max_);
71 void construct(
const std::vector<std::pair<double, double> >& intervals_,
72 std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1),
73 size_t number_of_pixels = 1000,
double min_ = -1,
double max_ = -1);
77 void PSSK::construct(
const std::vector<std::pair<double, double> >& intervals_,
78 std::vector<std::vector<double> > filter,
size_t number_of_pixels,
double min_,
double max_) {
81 std::cerr <<
"Entering construct procedure \n";
87 min_ = std::numeric_limits<int>::max();
88 max_ = -std::numeric_limits<int>::max();
90 for (
size_t i = 0; i != intervals_.size(); ++i) {
91 if (intervals_[i].first < min_) min_ = intervals_[i].first;
92 if (intervals_[i].second > max_) max_ = intervals_[i].second;
98 min_ -= fabs(max_ - min_) / 100;
99 max_ += fabs(max_ - min_) / 100;
103 std::cerr <<
"min_ : " << min_ << std::endl;
104 std::cerr <<
"max_ : " << max_ << std::endl;
105 std::cerr <<
"number_of_pixels : " << number_of_pixels << std::endl;
113 std::vector<std::vector<double> > heat_map_;
114 for (
size_t i = 0; i != number_of_pixels; ++i) {
115 std::vector<double> v(number_of_pixels, 0);
116 heat_map_.push_back(v);
118 this->heat_map = heat_map_;
120 if (dbg) std::cerr <<
"Done creating of the heat map, now we will fill in the structure \n";
122 for (
size_t pt_nr = 0; pt_nr != intervals_.size(); ++pt_nr) {
125 static_cast<int>((intervals_[pt_nr].first - this->min_) / (this->max_ - this->min_) * number_of_pixels);
127 static_cast<int>((intervals_[pt_nr].second - this->min_) / (this->max_ - this->min_) * number_of_pixels);
130 std::cerr <<
"point : " << intervals_[pt_nr].first <<
" , " << intervals_[pt_nr].second << std::endl;
131 std::cerr <<
"x_grid : " << x_grid << std::endl;
132 std::cerr <<
"y_grid : " << y_grid << std::endl;
137 x_grid -= filter.size() / 2;
138 y_grid -= filter.size() / 2;
142 std::cerr <<
"After shift : \n";
143 std::cerr <<
"x_grid : " << x_grid << std::endl;
144 std::cerr <<
"y_grid : " << y_grid << std::endl;
145 std::cerr <<
"filter.size() : " << filter.size() << std::endl;
149 for (
size_t i = 0; i != filter.size(); ++i) {
150 for (
size_t j = 0; j != filter.size(); ++j) {
152 if (((x_grid + i) >= 0) && (x_grid + i < this->heat_map.size()) && ((y_grid + j) >= 0) &&
153 (y_grid + j < this->heat_map.size())) {
155 std::cerr << y_grid + j <<
" " << x_grid + i << std::endl;
157 this->heat_map[y_grid + j][x_grid + i] += filter[i][j];
158 this->heat_map[x_grid + i][y_grid + j] += -filter[i][j];
A class implementing persistence heat maps.
Definition: Persistence_heat_maps.h:187
Definition: SimplicialComplexForAlpha.h:26
Persistence_heat_maps()
Definition: Persistence_heat_maps.h:193