global-vg-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 
00008 #ifndef PYRAMIDS_GLOBAL_VG_PYRAMID_MAKER_H
00009 #define PYRAMIDS_GLOBAL_VG_PYRAMID_MAKER_H
00010 
00011 #include <vector>
00012 #include <iostream>
00013 #include <set>
00014 #include <ext/hash_map>
00015 
00016 #include "clustering/hierarchical-clusterer.h"
00017 #include "histograms/multi-resolution-histogram.h"
00018 #include "point_set/point-set-list.h"
00019 #include "pyramids/vg-pyramid-maker.h"
00020 #include "tree/sparse-tree-node.h"
00021 #include "tree/sparse-tree.cc"
00022 #include "util/distance-computer.h"
00023 #include "util/sparse-vector.h"
00024 
00025 using namespace std;
00026 using namespace __gnu_cxx;
00027 
00028 namespace libpmk {
00029 
00032 class GlobalVGPyramidMaker : public VGPyramidMaker {
00033 public:
00034   GlobalVGPyramidMaker(const HierarchicalClusterer& clusterer,
00035                        const DistanceComputer& distance_computer);
00036   ~GlobalVGPyramidMaker();
00037 
00039 
00048   void Preprocess(const PointSetList& point_sets);
00049 
00050   virtual MultiResolutionHistogram* MakePyramid(const PointSet& point_set);
00051 
00053 
00057   void ReadFromStream(istream& input_stream);
00058 
00060 
00063   void ReadFromFile(const char* filename);
00064 
00066 
00080   void WriteToStream(ostream& output_stream) const;
00081 
00083 
00086   void WriteToFile(const char* filename) const;
00087 
00088 protected:
00090 
00097   virtual bool GetMembershipPath(const Point& f, LargeIndex* out_path,
00098                                  vector<double>* out_distances);
00099 
00100 private:
00101   // This maps a node ID to a double representing the size of that
00102   // node. Recall that the data used to preprocess a
00103   // GlobalVGPyramidMaker does not have to be the same as the data
00104   // used to cluster. Thus, there could be some nodes in the tree
00105   // which own no points. Those nodes simply do not show up in this
00106   // hash_map. (having an entry with size=0 is allowable; this is
00107   // the case for a node with 1 point in it).
00108   hash_map<int, double> node_sizes_;
00109 
00110   bool preprocessed_;
00111 };
00112 }  // namespace libpmk
00113 
00114 #endif  // PYRAMIDS_GLOBAL_VG_PYRAMID_MAKER_H

Generated on Fri Sep 21 11:39:04 2007 for libpmk2 by  doxygen 1.5.1