uniform-pyramid-maker.h

Go to the documentation of this file.
00001 // Copyright 2007, Massachusetts Institute of Technology.
00002 // The use of this code is permitted for research only. There is
00003 // absolutely no warranty for this software.
00004 //
00005 // Author: John Lee (jjl@mit.edu)
00006 //
00007 // TODO(jjl): what about turning new PointSets with min/max feature
00008 // value beyond min_value_ or max_value_? check for it and add a note in
00009 // the spec.
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 GetNumLevels() 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    // One vector per level. This is a num_levels * dim matrix.
00137    vector<vector<double> > translations_;
00138 
00139    // Make sure that the values (ints) are unique. We need to do this for
00140    // each level, so it's a vector of size num_levels_ of these mappings from
00141    // index to int.
00142    vector<map<LargeIndex, int> > vector_map_;
00143 
00144    // A vector of size num_levels. The ith entry tells you the last-used
00145    // value in vector_map_.
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 }  // namespace libpmk
00157 #endif  // PYRAMIDS_UNIFORM_PYRAMID_MAKER_H

Generated on Wed May 2 11:17:12 2007 for libpmk by  doxygen 1.5.1