00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef PYRAMIDS_UNIFORM_PYRAMID_MAKER_H
00011 #define PYRAMIDS_UNIFORM_PYRAMID_MAKER_H
00012
00013 #include <vector>
00014 #include <map>
00015 #include <iostream>
00016 #include "pyramids/pyramid-maker.h"
00017 #include "point_set/point-set-list.h"
00018 #include "point_set/point-set.h"
00019 #include "histograms/multi-resolution-histogram.h"
00020
00021 using namespace std;
00022
00023 namespace libpmk {
00024
00027
00039 class UniformPyramidMaker : public PyramidMaker {
00040 public:
00041 UniformPyramidMaker();
00042
00044
00059 void Preprocess(const PointSetList& point_sets,
00060 double finest_side_length,
00061 double side_factor,
00062 int discretize_factor,
00063 bool do_translations,
00064 bool global_translations);
00065
00067 void Preprocess(const vector<PointRef>& points,
00068 double finest_side_length,
00069 double side_factor,
00070 int discretize_factor,
00071 bool do_translations,
00072 bool global_translations);
00073
00075
00078 void ReadFromStream(istream& input_stream);
00079
00081
00084 void ReadFromFile(const char* filename);
00085
00087
00090 void WriteToStream(ostream& output_stream) const;
00091
00093
00096 void WriteToFile(const char* filename) const;
00097
00099
00102 int num_levels() const;
00103
00105
00118 virtual MultiResolutionHistogram* MakePyramid(const PointSet& ps);
00119
00120
00121 private:
00122 double finest_side_length_;
00123 double side_factor_;
00124 int discretize_factor_;
00125 int feature_dim_;
00126 bool do_translations_;
00127 bool global_translations_;
00128 bool preprocessed_;
00129
00130 double min_value_;
00131 double max_value_;
00132
00133 double diameter_;
00134 int num_levels_;
00135
00136
00137 vector<vector<double> > translations_;
00138
00139
00140
00141
00142 vector<map<LargeIndex, int> > vector_map_;
00143
00144
00145
00146 vector<int> last_vector_map_values_;
00147
00148 int GetSparseValue(int level, const LargeIndex& index);
00149 void ComputeHistogramSettings(int dim,
00150 double finest_side_length,
00151 double side_factor,
00152 int discretize_factor,
00153 bool do_translations,
00154 bool global_translations);
00155 };
00156 }
00157 #endif // PYRAMIDS_UNIFORM_PYRAMID_MAKER_H